Skip to content

Commit

Permalink
Merge pull request #4 from wirenboard/feature/43446-wb7-cpu-serial-fr…
Browse files Browse the repository at this point in the history
…om-devmem

WB7 cpu serial from devmem
  • Loading branch information
webconn authored Dec 26, 2021
2 parents 6b53ee2 + 4cd8cdb commit 401a1ba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildDebArchAll()
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-common (1.4.0) stable; urgency=medium

* add procedure to read WB7 serial from /dev/mem

-- Nikita Maslov <nikita.maslov@wirenboard.ru> Tue, 07 Dec 2021 16:16:43 +0300

wb-common (1.3.3) stable; urgency=medium

* beeper: fix stucking in beeping state
Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ X-Python3-Version: >= 3.2

Package: python-wb-common
Architecture: all
Depends: python, ${misc:Depends}, python-six
Depends: python, ${misc:Depends}, python-six, busybox
Description: Wiren Board Python common library and helpers

Package: python3-wb-common
Architecture: all
Depends: python3, ${misc:Depends}, python3-six
Depends: python3, ${misc:Depends}, python3-six, busybox
Description: Wiren Board Python common library and helpers
14 changes: 14 additions & 0 deletions wb_common/uid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import print_function
import re
import os
import subprocess

# get_mac() has been moved to test_suite, because it uses wb-gen-serial,
# which depends on this (wb-common) package (avoid circular dependency)
Expand All @@ -14,6 +15,19 @@ def get_cpuinfo_serial():
return None


def _devmem(address):
r = subprocess.check_output('busybox devmem 0x{:x} 32'.format(address), shell=True)
return int(r, 16)


def get_wb7_cpu_serial():
r3 = _devmem(0x1c1b20c)
r2 = _devmem(0x1c1b208)
r1 = _devmem(0x1c1b204)

return format(r3, '08x') + format(r2, '08x') + format((r1 >> 16) & 0xFFFF, '04x')


def get_mmc_serial():
mmc_prefix = '/sys/class/mmc_host/mmc0/'
if os.path.exists(mmc_prefix):
Expand Down

0 comments on commit 401a1ba

Please sign in to comment.