You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shell command "devmem load" works properly only if the address parameter is less than 0x80000000. If it is equal to or above 0x80000000, then a bus fault will occur after the first byte (i.e. the first two hex characters) have been entered into the shell.
The problem is that cmd_load() is using strtol() when assigning to bytes and data. Everywhere else in zephyr/subsys/shell/modules/devmem_service.c uses strtoul(). This seems to be an oversight in the cmd_load() function since addresses can never be negative.
If the value is outside the range of a signed long, then strtol() returns LONG_MAX, which in my case is 0x7FFFFFFF. This then gets used as the address to start writing bytes to. As soon as the first byte is entered in the shell, bypass_cb() tries to write it and bus faults.
To Reproduce
Steps to reproduce the behavior:
Choose any MCU that places a memory region above 0x80000000. In my case, the STM32H7 maps the external SDRAM starting at 0xC0000000.
Ensure that the shell is enabled. CONFIG_SHELL=y in prj.conf.
Build and flash the board and connect a terminal program to the shell
Issue command devmem load 0xC0000000
Start typing hexadecimal characters
After 2 characters, a bus fault occurs
Expected behavior
"devmem load" works for addresses above 0x80000000.
Impact
Minimal. I can work around this, by changing the strotol() calls to strtoul(), but it requires managing and applying a Zephyr patch file in the West workspace.
Describe the bug
Shell command "devmem load" works properly only if the address parameter is less than 0x80000000. If it is equal to or above 0x80000000, then a bus fault will occur after the first byte (i.e. the first two hex characters) have been entered into the shell.
The problem is that
cmd_load()
is usingstrtol()
when assigning tobytes
anddata
. Everywhere else inzephyr/subsys/shell/modules/devmem_service.c
usesstrtoul()
. This seems to be an oversight in thecmd_load()
function since addresses can never be negative.If the value is outside the range of a signed long, then
strtol()
returnsLONG_MAX
, which in my case is 0x7FFFFFFF. This then gets used as the address to start writing bytes to. As soon as the first byte is entered in the shell,bypass_cb()
tries to write it and bus faults.To Reproduce
Steps to reproduce the behavior:
CONFIG_SHELL=y
inprj.conf
.devmem load 0xC0000000
Expected behavior
"devmem load" works for addresses above 0x80000000.
Impact
Minimal. I can work around this, by changing the
strotol()
calls tostrtoul()
, but it requires managing and applying a Zephyr patch file in the West workspace.Logs and console output
0x08009004 is in
shell_process()
.0x0800884d is in
bypass_cb()
.Environment (please complete the following information):
Additional context
None
The text was updated successfully, but these errors were encountered: