Code Monkey home page Code Monkey logo

tockloader's People

Contributors

1c3t3a avatar alevy avatar alexandruradovici avatar bradjc avatar brghena avatar daniel-scs avatar dc740 avatar gentooza avatar hudson-ayers avatar ibibgor avatar james-lomax avatar joe1994 avatar jrvanwhy avatar krady21 avatar lschuermann avatar lthiery avatar niklasad1 avatar phil-levis avatar ppannuto avatar pqcfox avatar twilfredo avatar wprzytula avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tockloader's Issues

Failure when parsing a TBF with trailing padding.

After updating elf2tab to a commit that includes tock/elf2tab#81, I'm seeing the following crash in Tockloader:

[INFO   ] Using settings from KNOWN_BOARDS["opentitan_earlgrey"]
[INFO   ] Operating on flash file "bazel-out/k8-fastbuild-ST-2cc462681f62/bin/sw/device/silicon_owner/tock/tests/basic/image1.bin".
[INFO   ] Limiting flash size to 0x100000 bytes.
[STATUS ] Installing app on the board...
[DEBUG  ] start: Enter bootloader mode
[DEBUG  ] start: Determine current board
[DEBUG  ] start: Update board specific options
[DEBUG  ] Could not determine kernel version.
Traceback (most recent call last):
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/execroot/lowrisc_opentitan/bazel-out/k8-opt-exec-2B5CBBC6-ST-e846b08c7501/bin/external/tockloader_deps/pypi__tockloader/rules_python_wheel_entry_point_tockloader.runfiles/tockloader_deps/pypi__tockloader/rules_python_wheel_entry_point_tockloader.py", line 5, in <module>
    rc = main()
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/main.py", line 1459, in main
    args.func(args)
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/main.py", line 168, in command_install
    tock_loader.install(tabs, replace=replace, erase=args.erase, sticky=args.sticky)
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/tockloader.py", line 340, in install
    replacement_apps = self._extract_apps_from_tabs(tabs, arch)
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/tockloader.py", line 1647, in _extract_apps_from_tabs
    app = tab.extract_app(arch)
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/tab.py", line 85, in extract_app
    tabtbf = self._extract_tbf_from_filebuffer(tbf_filename, binary)
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/tab.py", line 255, in _extract_tbf_from_filebuffer
    tbff = TBFFooter(tbfh, app_binary, binary[start_of_footers:])
  File "/home/jrvanwhy/.cache/bazel/_bazel_jrvanwhy/33a7c06cd67612f3e3f6059a552c3123/external/tockloader_deps/pypi__tockloader/tockloader/tbfh.py", line 1843, in __init__
    base = struct.unpack("<HH", buffer[0:4])
struct.error: unpack requires a buffer of 4 bytes

nrf52840dk different tockloader listen behavior

For most boards in Tock, you pass the same commands to tockloader listen as you do to most other tockloader commands. For the nrf52840dk, however, this is not the case.

To install, or erase-apps, or list on the nrf52840dk, you use

tockloader [command] --board nrf52dk --jlink

However in order to listen, you must use just

tockloader listen and then press the reset button.

For the nrf52840dk, tockloader listen does not reset the board like it does for Hail or Imix, so if you have an app that only prints near startup you will not see any output without resetting the board

tockloader is annoying about argument order

$ tockloader listen --port /dev/tty.usbserial-000011
usage: tockloader [-h] [--port PORT] {flash,listen} ...
tockloader: error: unrecognized arguments: --port /dev/tty.usbserial-000011
$ tockloader --port /dev/tty.usbserial-000011 listen
Hello World!

Macports: Python 3.6: tockloader executable not created by pip?

When I installed tockloader under Mac Ports, it seems like the tockloader binary was not created?

My installation was:

sudo port install python36-pip
sudo port install py36-pip
sudo -H pip-3.6 install tockloader

However, there was no tockloader binary installed?

I ended up doing:

sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tockloader/main.py /opt/local/bin/tockloader
sudo chmod a+x /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tockloader/main.py

Below is what happens when I try again to install tockloader, which looks OK to me:

bash-3.2$ sudo -H pip-3.6 install tockloader
Requirement already satisfied: tockloader in /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: pyserial>=3.0.1 in /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tockloader)
Requirement already satisfied: crcmod>=1.7 in /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tockloader)

The directory contents are below:

bash-3.2$ ls /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
README                                  easy_install.py                         setuptools
README.txt                              pip                                     setuptools-32.3.0-py3.6.egg-info
__pycache__                             pip-9.0.1-py3.6.egg-info                tockloader
crcmod                                  pkg_resources                           tockloader-0.1.0.dist-info
crcmod-1.7-py3.6.egg-info               pyserial-3.2.1.dist-info                tockloader-0.2.0-py3.6.egg
easy-install.pth                        serial
bash-3.2$ ls /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tockloader
__init__.py     __pycache__     main.py

Here's the link I created:

bash-3.2$ ls -l /opt/local/bin/tockloader 
lrwxr-xr-x  1 root  admin  106 Dec 28 19:17 /opt/local/bin/tockloader -> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tockloader/main.py

This might be a Mac Port-specific problem, I could retry with Brew.

OpenOCD support for NRF

Hi,

with version 0.10.0, OpenOCD gained a couple of improvements for the NRF chips. I wrote a small script that is able to flash kernel and app bundles. Now I'm interested in adding support for openocd to tockloader, since openocd seems to be much more available than the jlink and it has support for different programmers aswell. Flashing an NRF via stlink is possible aswell.

So far my understanding it that I need to implement the BoardInterface for openocd. Is there anything else I need to take into consideration?

Passing multiple apps to `flash` does not align them

$ tockloader flash build/cortex-m4/app.bin ../../sensors/build/cortex-m4/app.bin
...
$ tockloader list
No serial port specified. Discovering attached serial devices...
Using "/dev/cu.usbserial-003032 - Hail IoT Module - TockOS - Hail IoT Module - TockOS"
[App 0]
  Name:                  printf_long
  Total Size in Flash:   4096 bytes

[App 1]
  Name:                  sensors
  Total Size in Flash:   8192 bytes
  [WARNING] App is misaligned for the MPU

Ubuntu subsystem does not autofind "tock" board

imix and hail try to name the FTDI serial port with "tock" in the name, but for some reason that doesn't work with Ubuntu for Windows. I'm not sure if it is supposed to, or if we need to use the serial library in a different way.

Add progress bar

Would be neat to have a progress bar. Maybe only for flash/install operations as those can take a while, but maybe more broadly as well.

OpenOCD is sometimes given the wrong path for Arty A7 bitfiles

On certain systems after installing tockloader from source, OpenOCD will error out when trying to find the E21 Arty A7 bitfile when trying to do any operation that connects with the Arty A7 board.

For instance, on Ubuntu 20.04 using Python 3.8 with pyenv, tockloader tells OpenOCD that the path of the bitfile should be

/usr/local/lib/python3.8/site-packages/tockloader/bitfiles/bscan_spi_xc7a100t.bit

whereas the actual bitfile is installed in /usr/local/bitfiles/bscan_spi_xc7a100t.bit.


The root of the problem appears to be that OpenOCD is fed the path to bscan_spi_xc7a100t.bit as

<tockloader package path>/../bitfiles/bscan_spi_xc7a100t.bit.

Due to variations across systems of where data_files places files, this path can sometimes differ from the actual path where the bitfile is installed.

Tockloader listen resumption should remember port

If you have multiple hails plugged in and one terminal is listening, if you perform an operation in another terminal when the listening hail resumes it'll ask which hail it should listen to, when it should just resume listening to the same hail.

Machine readable output

When using tockloader in a testing context, where a script is using tockloader to program a board, the current human-readable tockloader output is not particularly useful (and is also not guaranteed to change, and, perhaps relatedly, changes all of the time). Tockloader should support some sort of flag to give machine readable output.

Features to add this for:

  • tockloader list: At the very least, getting the status of the board would be helpful. That way a tool can try to program the board, and then at least check the board is in the state it expects.

Handle when a .tab does not have a binary for the board arch

Trying to flash a tab compiled for RISC-V on hail crashed tockloader.

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/tab.py", line 40, in extract_app
    binary_tarinfo = self.tab.getmember('{}.tbf'.format(arch))
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tarfile.py", line 1754, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'cortex-m4.tbf' not found"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/tockloader", line 11, in <module>
    load_entry_point('tockloader==1.4.0.dev0', 'console_scripts', 'tockloader')()
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/main.py", line 593, in main
    args.func(args)
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/main.py", line 130, in command_install
    tock_loader.install(tabs, replace=replace, erase=args.erase)
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/tockloader.py", line 101, in install
    replacement_apps = self._extract_apps_from_tabs(tabs)
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/tockloader.py", line 619, in _extract_apps_from_tabs
    apps.append(tab.extract_app(arch))
  File "/usr/local/lib/python3.7/site-packages/tockloader-1.4.0.dev0-py3.7.egg/tockloader/tab.py", line 42, in extract_app
    binary_tarinfo = self.tab.getmember('{}.bin'.format(arch))
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tarfile.py", line 1754, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'cortex-m4.bin' not found"

Flashing apps via openocd error

I am using tockloader --openocd to upload apps to the microbit v2. I have a very strange behavior:

  • writing the first app works
  • writing a second app will erase all apps

Using the tockloader with the serial bootloader seems to work fine.

alex@alex-PC-i5:~/projects/tock/libtock-c/examples$ tockloader info --board microbit_v2 --openocd 
[INFO   ] Using settings from KNOWN_BOARDS["microbit_v2"]
tockloader version: 1.6.0
[STATUS ] Showing all properties of the board...
Apps:
[INFO   ] No found apps.
Attributes:
00:    board = microbit_v2
01:     arch = cortex-m4
02:  appaddr = 0x40000
03: boothash = d07821e78b75d811de62f997de51808a50c38395
04:
05:
06:
07:
08:
09:
10:
11:
12:
13:
14:
15:

Bootloader version: v1.1.1
[INFO   ] Finished in 2.084 seconds
alex@alex-PC-i5:~/projects/tock/libtock-c/examples$ tockloader install --board microbit_v2 --openocd --debug c_hello/build/c_hello.tab
[INFO   ] Using settings from KNOWN_BOARDS["microbit_v2"]
[STATUS ] Installing app on the board...
[DEBUG  ] Using read command: "dump_image {{binary}} {address:#x} {length};"
[DEBUG  ] Expanded read command: "dump_image {binary} 0x40000 200;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; dump_image /tmp/tmplbaeet_p.bin 0x40000 200;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
dumped 200 bytes in 0.009903s (19.723 KiB/s)

[DEBUG  ] Found 0 apps on the board.
[INFO   ] Flashing app c_hello binary to board.
[DEBUG  ] Using program command: "program {{binary}} verify {address:#x};"
[DEBUG  ] Expanded program command: "program {binary} verify 0x40000;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; program /tmp/tmpd_r9gila.bin verify 0x40000;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
** Programming Started **
auto erase enabled
Warn : Unknown device (HWID 0x00000197)
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
wrote 4096 bytes from file /tmp/tmpd_r9gila.bin in 0.516984s (7.737 KiB/s)
** Programming Finished **
** Verify Started **
verified 2048 bytes in 0.220032s (9.090 KiB/s)
** Verified OK **

[DEBUG  ] Erasing page at address 0x40800
[DEBUG  ] Using erase command: "flash fillb 0x40800 0xff 512;"
[DEBUG  ] Expanded erase command: "flash fillb 0x40800 0xff 512;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; flash fillb 0x40800 0xff 512;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
Warn : Unknown device (HWID 0x00000197)
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
wrote 512 bytes to 0x00040800 in 0.690999s (0.724 KiB/s)

[INFO   ] Finished in 3.242 seconds
alex@alex-PC-i5:~/projects/tock/libtock-c/examples$ tockloader info --board microbit_v2 --openocd 
[INFO   ] Using settings from KNOWN_BOARDS["microbit_v2"]
tockloader version: 1.6.0
[STATUS ] Showing all properties of the board...
Apps:
┌──────────────────────────────────────────────────┐
│ App 0                                            |
└──────────────────────────────────────────────────┘
  Name:                  c_hello
  Enabled:               True
  Sticky:                False
  Total Size in Flash:   2048 bytes
  Address in Flash:      0x40000
    version               : 2
    header_size           :         44         0x2c
    total_size            :       2048        0x800
    checksum              :              0x65202923
    flags                 :          1          0x1
      enabled             : Yes
      sticky              : No
    TLV: Main (1)
      init_fn_offset      :         41         0x29
      protected_size      :          0          0x0
      minimum_ram_size    :       4612       0x1204
    TLV: Package Name (3)
      package_name        : c_hello


Attributes:
00:    board = microbit_v2
01:     arch = cortex-m4
02:  appaddr = 0x40000
03: boothash = d07821e78b75d811de62f997de51808a50c38395
04:
05:
06:
07:
08:
09:
10:
11:
12:
13:
14:
15:

Bootloader version: v1.1.1
[INFO   ] Finished in 2.603 seconds
alex@alex-PC-i5:~/projects/tock/libtock-c/examples$ tockloader install --openocd --board microbit_v2 --debug blink/build/blink.tab 
[INFO   ] Using settings from KNOWN_BOARDS["microbit_v2"]
[STATUS ] Installing app on the board...
[DEBUG  ] Using read command: "dump_image {{binary}} {address:#x} {length};"
[DEBUG  ] Expanded read command: "dump_image {binary} 0x40000 200;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; dump_image /tmp/tmp0ryersan.bin 0x40000 200;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
dumped 200 bytes in 0.009930s (19.669 KiB/s)

[DEBUG  ] Using read command: "dump_image {{binary}} {address:#x} {length};"
[DEBUG  ] Expanded read command: "dump_image {binary} 0x40800 200;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; dump_image /tmp/tmpphki17fn.bin 0x40800 200;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
dumped 200 bytes in 0.009952s (19.625 KiB/s)

[DEBUG  ] Found 1 app on the board.
[DEBUG  ]   1. c_hello
[INFO   ] Flashing app blink binary to board.
[DEBUG  ] Using program command: "program {{binary}} verify {address:#x};"
[DEBUG  ] Expanded program command: "program {binary} verify 0x40800;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; program /tmp/tmp70idcvvx.bin verify 0x40800;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
** Programming Started **
auto erase enabled
Warn : Unknown device (HWID 0x00000197)
Warn : Adding extra erase range, 0x00040000 to 0x000407ff
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
wrote 2048 bytes from file /tmp/tmp70idcvvx.bin in 0.602974s (3.317 KiB/s)
** Programming Finished **
** Verify Started **
verified 2048 bytes in 0.217993s (9.175 KiB/s)
** Verified OK **

[DEBUG  ] Erasing page at address 0x41000
[DEBUG  ] Using erase command: "flash fillb 0x41000 0xff 512;"
[DEBUG  ] Expanded erase command: "flash fillb 0x41000 0xff 512;"
[DEBUG  ] Running "openocd -c "source [find interface/cmsis-dap.cfg]; 		                                   transport select swd; 	                                   source [find target/nrf52.cfg]; 		                                   set WORKAREASIZE 0x40000;                                    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $WORKAREASIZE -work-area-backup 0; 	                                   flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME;  init; reset init; halt; flash fillb 0x41000 0xff 512;  exit"".
[INFO   ] Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : reduce speed request: 10000kHz to 5000kHz maximum
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001024 msp: 0x20002000
Warn : Unknown device (HWID 0x00000197)
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
wrote 512 bytes to 0x00041000 in 0.689007s (0.726 KiB/s)

[INFO   ] Finished in 3.838 seconds
alex@alex-PC-i5:~/projects/tock/libtock-c/examples$ tockloader info --board microbit_v2 --openocd 
[INFO   ] Using settings from KNOWN_BOARDS["microbit_v2"]
tockloader version: 1.6.0
[STATUS ] Showing all properties of the board...
Apps:
[INFO   ] No found apps.
Attributes:
00:    board = microbit_v2
01:     arch = cortex-m4
02:  appaddr = 0x40000
03: boothash = d07821e78b75d811de62f997de51808a50c38395
04:
05:
06:
07:
08:
09:
10:
11:
12:
13:
14:
15:

Bootloader version: v1.1.1
[INFO   ] Finished in 2.074 seconds

Mixing fixed position and PIC apps

Tockloader currently has 2 separate paths for flashing: one for when all apps are PIC and can go anywhere in the flash, and one for when all have fixed positions in the flash (possibly multiple fixed positions).

This separation fundamentally doesn't have to exist, because (presumably) Tock kernel can make sense out of applications and where to put them if it gets a mix of both.

With libtock-c producing PIC binaries, and libtock-rs producing only fixed ones, until this issue is solved, programs using them cannot coexist.

I'm creating this issue as a place to discuss solving this.

'uninstall' and 'install' should have auto-name parity

If I run tockloader install and tockloader uninstall back to back, the first will work since it picks up an application name from the current directory, but the second will fail; feels like it should also grab a default name using the same rules

Uncaught exception on Python 3.8+

Every tockloader run terminates with an exception:

$ tockloader list
[INFO   ] No device name specified. Using default name "tock".
[INFO   ] Using "/dev/cu.usbserial-c098e513000e - Hail IoT Module - TockOS - Hail IoT Module - TockOS".
┌──────────────────────────────────────────────────┐
│ App 0                                            |
└──────────────────────────────────────────────────┘
  Name:                  hail
  Enabled:               True
  Sticky:                False
  Total Size in Flash:   65536 bytes


[INFO   ] Finished in 1.884 seconds
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner

I think this is related to https://docs.python.org/3/whatsnew/3.8.html#threading, which changes how exceptions in background threads are handled.

This was likely always a "problem"; I'm guessing that we are technically supposed to in some way cleanly shut down the server thread rather than just killing it off. It's not really a problem-problem, since this is an exception that triggers during shutdown, so we don't really care, but cosmetically it's pretty undesirable.

I spent a few minutes poking around, but it's not immediately obvious what the right fix is.

Unable to install blink app nucleo f446re

I have a nucleo f446re board, on which I flashed Tock over the embedded debugger. I then tried to install the blink app using tockloader, but it did not work. However, with tockloader listen I get a initialization message at restart, so the communication should work fine.
Any suggestions what I might do wrong?

Auto device selection confusing

If you say "listen -d radio", but you don't have a radio plugged in, but do have another serial device (like "module0"), it will connect to the other device.

It prints a message, but that gets a bit lost. Needs to be more obvious that it's doing that, or maybe not connect to just any port it can find if -d is used.

Timestamp / count don't always catch newlines? :(

Posting for later investigation, but a device printing like this:

        printf("\r");
        for (j=0; j<adv.dlen; j++) {
          printf("%02x", adv.data[j]);
        }
        printf("\n");

doesn't result in the timestamp / count option working, which is a bit surprising as I'd expect that lone '\n' at the end to make things happy

nrf52 small apps don't work with jlink

Ever since the change to support board-specific flash page sizes, small apps don't stay on the board when using jlink. They seem to get flashed ok, but then something about verifying that causes the app to be removed somehow.

listen probably shouldn't pause another listen

Then you get in a situation where it's a nested set of terminals who resume listening. The bigger problem is once the second listen is active, a third tockloader is then blocked from running as "another tockloader process is active".

Basically, we should special-case the pausing of another tockloader process such that if the new one is a listen, it bails out instead.

Microbit_v2 doesn't reset after flashing

When you use Tockloader to install an application or kernel on a Microbit_v2, you must also manually press the reset button afterwards to make the app start. It's not really a bug, but it seems undesirable to me.

So my question: do other boards automatically restart after flashing?

This is solved by adding the flag --openocd-options resume, although that restarts the running application many times, not just once after finishing the program upload. Should that flag be added as a default for the Microbit_v2?

OpenOCD Flash Failure

I am attempting to flash tock using the OpenOCD option in tockloader. I modified the Makefile to look like this:

TOCKLOADER_JTAG_FLAGS = --board nrf52dk --openocd --openocd-board /usr/share/openocd/scripts/board/nordic_nrf52_dk.cfg --debug

I get the following output:

text	   data	    bss	    dec	    hex	filename
 114176	   1708	 260436	 376320	  5be00	target/thumbv7em-none-eabi/release/nrf52840_dongle
sudo tockloader  flash --address 0x00000 --board nrf52dk --openocd --openocd-board /usr/share/openocd/scripts/board/nordic_nrf52_dk.cfg --debug target/thumbv7em-none-eabi/release/nrf52840_dongle.bin
Flashing binar(y|ies) to board...
Using known arch and jtag-device for known board nrf52dk
Running "openocd -c "source [find board/nordic_nrf52_dk.cfg]; init; reset init; halt; program /tmp/tmpuqe6n6cn.bin verify 0x0; soft_reset_halt; resume; exit"".
ERROR: openocd returned with error code 1
Open On-Chip Debugger 0.10.0+dev-01058-g853a05287 (2020-02-11-20:48)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Error: No J-Link device found.


openocd error

I have openocd configured to use an FTDI FT2232H mini module. I have also changed --openocd-board to point to the programmer interface config path as well, the same error persists.

System details:

  • Linux 5.4.14
  • OpenOCD 0.10.0

can't use tockloader on nRF51dk

Hi,
I can't manage to get tockloader to flash userapps in TockOS

Version info:

➜  ~ uname -a                  
Linux desktop 4.11.9-1-ARCH #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017 x86_64 GNU/Linux
➜  ~ lsb_release -a
LSB Version:	1.4
Distributor ID:	Arch
Description:	Arch Linux
Release:	rolling
Codename:	n/a
➜  tock git:(master) ✗ tockloader --version                                        
0.7.1

When I flash the board everything looks fine:

➜  blink git:(master) ✗ tockloader install --jtag --board nrf51dk --arch cortex-m0
No TABs passed to tockloader. Searching for TABs in subdirectories.
Using: ['./build/blink.tab']
Waiting one second before continuing...
Installing apps on the board...
Finished in 1.446 seconds

But the LEDs don't blink!!

Listen works:

➜  blink git:(master) ✗ tockloader listen
No device name specified. Using default "tock"
No serial port with device name "tock" found
Found 3 serial port(s).

[0]	/dev/ttyS1 - n/a
[1]	/dev/ttyS0 - ttyS0
[2]	/dev/ttyACM0 - J-Link - CDC

Which option? [0] 2

Listening for serial output.
TOCK_DEBUG(0): src/main.rs:284: Initialization complete. Entering main loop

List don't work

➜  blink git:(master) ✗ tockloader list  
No device name specified. Using default "tock"
No serial port with device name "tock" found
Found 3 serial port(s).

[0]	/dev/ttyS1 - n/a
[1]	/dev/ttyS0 - ttyS0
[2]	/dev/ttyACM0 - J-Link - CDC

Which option? [0] 2

Error connecting to bootloader. No "pong" received.
Things that could be wrong:
  - The bootloader is not flashed on the chip
  - The DTR/RTS lines are not working
  - The serial port being used is incorrect
  - The bootloader API has changed
  - There is a bug in this script
Could not attach to the bootloader

What am I doing wrong?

Next release will be 1.0

My plan is for the next release of Tockloader to be 1.0. The core interface hasn't changed in months, and only the --jtag (and related) flags have changed (although the old ones are still supported). No one seems to be complaining about the interface, and I've been happy with it.

I think that commands and features will continue to be added (and have been), but the general install/uninstall/flash/listen interface will be formally stabilized.

Feature Request: Signal `tockloader listen` processes

In my experience any tockloader command will fail if another terminal has tockloader listen running. Therefore it would be nice if on any command, tockloader would signal all other tockloader processes, and if those were tockloader listen on the same port, they would release the serial port, wait for the signalling process to finish, and then resume listen. This would make tockloader work seamlessly with itself.

Note: I'm not actually sure what the best way to get tockloader processes to communicate is.

New release on pip3?

OpenSK's deploy script depends on the App.get_binary() function from tockloader.

def get_binary (self):
'''
Return the binary array comprising the entire application.
'''
binary = self.tbfh.get_binary() + self.app_binary
# Check that the binary is not longer than it is supposed to be. This
# might happen if the size was changed, but any code using this binary
# has no way to check. If the binary is too long, we truncate the actual
# binary blob (which should just be padding) to the correct length. If
# it is too short it is ok, since the board shouldn't care what is in
# the flash memory the app is not using.
size = self.get_size()
if len(binary) > size:
binary = binary[0:size]
return binary

However, this function is not available in the latest released version of tockloader on pip3. This causes some failures: google/OpenSK#79.

Could you release a new version of tockloader on pip3?

Dropped Messages

It seems like tockloader listen drops the first messages that are printed using the debug! macro. Here is the context:

  • I flash the stock kernel onto the nano 33.
  • I flash the c_hello program onto the nano33.
  • I execute tockloader listen.
  • I expect to see "Initialization complete. Entering main loop." printed.
  • I do not see this.

As a remedy suggested by Hudson, I added a bunch of copies of the debug! macro (shown below) and am able to—non-deterministically—see some of the last statements.

Screen Shot 2020-11-24 at 2 46 44 PM

Here are some example runs:

❯ tockloader listen
[INFO   ] No device name specified. Using default name "tock".
[INFO   ] Using "/dev/cu.usbmodem14301 - Nano 33 BLE _ TockOS".
[INFO   ] Listening for serial output.
omplete. Entering main loop.
Initialization complete. Entering main loop.
Initialization complete. Entering main loop.
Initialization complete. Entering main loop.
Initialization complete. Entering main loop.
Hello World!
❯ tockloader listen
[INFO   ] No device name specified. Using default name "tock".
[INFO   ] Using "/dev/cu.usbmodem14301 - Nano 33 BLE _ TockOS".
[INFO   ] Listening for serial output.
main loop.
Initialization complete. Entering main loop.
Initialization complete. Entering main loop.
Initialization complete. Entering main loop.
Hello World!

I'm using this duplication strategy right now because I don't have the bandwidth to debug this, but I've made an issue to document the bug.

flashing with fails with v1.8.0

I'm running tockloader installed with pip on my Debian system with an Arty A7 100T.

$ openocd --version
Open On-Chip Debugger 0.11.0
$ tockloader --version
1.8.0
$ tockloader install --openocd --board arty blink --debug

It fails to load the flash proxy, as it's looking inside the local python install path:

Debug: 158 32 command.c:146 script_debug(): command - pld load 0 /home/joel/.local/lib/python3.9/site-packages/tockloader/../bitfiles/bscan_spi_xc7a100t.bit
Error: 160 32 xilinx_bit.c:81 xilinx_read_bit_file(): couldn't stat() /home/joel/.local/lib/python3.9/site-packages/tockloader/../bitfiles/bscan_spi_xc7a100t.bit: No such file or directory

make install worked fine, as it uses the proxy from tock/boards/arty_e21/openocd.

The full output can be seen here:

http://paste.debian.net/hidden/1ecbb370/

App start address is incorrect for nrf52-dk

The app start address for nrf52-dk is 0x20000 instead of 0x30000 which is the default. This causes tockloader to fail flashing apps for nrf52-dk if one doesn't supply the app-start-address explictly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.