zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.73k stars 6.55k forks source link

help to use zephyr-ninja flash of st_nucleo_l476rg #15448

Closed chaos4284 closed 5 years ago

chaos4284 commented 5 years ago

My system is WUL(Ubuntu 18.04) of Windows 10. I can cmake the project sample/hello_world, then when I flash to the board the error open:

[0/1] Flashing nucleo_l476rg
Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-g0b1cbf175-dirty (2019-03-08-20:54)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to         
plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Error: open failed

**ERROR: command exited with status 1: /opt/zephyr-sdk/sysroots/x86_64-pokysdk-    
linux/usr/bin/openocd -s /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -    
f /home/zephyrproject/zephyr/boards/arm/nucleo_l476rg/support/openocd.cfg -c init -c targets -c     
'reset halt' -c 'flash write_image erase     
/home/zephyrproject/zephyr/samples/hello_world/build/zephyr/zephyr.elf' -c 'reset halt' -c 
'verify_image /home/zephyrproject/zephyr/samples/hello_world/build/zephyr/zephyr.elf' -c 'reset run'     
-c shutdown**

run as "west -v flash --skip-rebuild" for a stack trace
FAILED: zephyr/cmake/flash/CMakeFiles/flash
cd /home/zephyrproject/zephyr/samples/hello_world/build && /home/kwon/cmake-3.13.1-Linux-    
x86_64/bin/cmake -E env /usr/local/bin/west flash --skip-rebuild
ninja: build stopped: subcommand failed.

I confirmed that flash works well in windows TrueSTUDIO.

Can you find a solution to this problem?

mbolivar commented 5 years ago

Hi @chaos4284 and thanks for the report.

My system is WUL(Ubuntu 18.04) of Windows 10.

I am not 100% sure, but I don't think you can flash devices from the WSL command line, as the /dev tree there doesn't mirror the windows device tree completely.

Can you try building and flashing using an installation built with cmd.exe instead? The getting started guide (https://docs.zephyrproject.org/latest/getting_started/index.html) has a windows sub-page with the details.

If that works, then it's an issue with WSL and flashing, not Zephyr's build and flash code.

chaos4284 commented 5 years ago

In using cmd.exe, Occur still problem .

[0/1] Flashing nucleo_l476rg
Traceback (most recent call last):
File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec)
File "c:\python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\Python37\Scripts\west.exe\__main__.py", line 9, in <module>
File "c:\python37\lib\site-packages\west\_bootstrap\main.py", line 499, in main wrap(wrap_argv)
File "c:\python37\lib\site-packages\west\_bootstrap\main.py", line 485, in wrap  west.main.main(argv)
File "C:\zephyrproject\.west\west\src\west\main.py", line 580, in main args.handler(args, unknown)
File "C:\zephyrproject\.west\west\src\west\main.py", line 332, in ext_command_handler 
command.run(*west_parser.parse_known_args(argv))
File "C:\zephyrproject\.west\west\src\west\commands\command.py", line 90, in run
self.do_run(args, unknown)
File "c:\zephyrproject\zephyr\scripts\west_commands\flash.py", line 32, in do_run
'ZEPHYR_BOARD_FLASH_RUNNER')
File "C:\zephyrproject\zephyr\scripts/west_commands\run_common.py", line 151, in do_run_common
build_dir = _build_dir(args)
File "C:\zephyrproject\zephyr\scripts/west_commands\run_common.py", line 135, in _build_dir
elif is_zephyr_build(cwd):
File "C:\zephyrproject\.west\west\src\west\build.py", line 31, in is_zephyr_build
cache = cmake.CMakeCache.from_build_dir(path)
File "C:\zephyrproject\.west\west\src\west\cmake.py", line 166, in from_build_dir
return CMakeCache(os.path.join(build_dir, DEFAULT_CACHE))
File "C:\zephyrproject\.west\west\src\west\cmake.py", line 170, in __init__
self.load(cache_file)
File "C:\zephyrproject\.west\west\src\west\cmake.py", line 175, in load
for line_no, line in enumerate(cache):
**UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 1237: illegal multibyte                     
sequence
FAILED: zephyr/cmake/flash/CMakeFiles/flash**cmd.exe /C "cd /D                 
C:\zephyrproject\zephyr\samples\hello_world\build && "C:\Program Files\CMake\bin\cmake.exe" -E             
env C:/Python37/Scripts/west.exe flash --skip-rebuild"
ninja: build stopped: subcommand failed.

Occupying the error, I modified Line 174 of C:\zephyrproject.west\west\src\west\cmake.py.

~from with open(cache_file, 'r') as cache: ~to with open(cache_file, 'r', encoding = "utf-8") as cache:

Afterward that. following error still occupied.

[0/1] Flashing nucleo_l476rg
Using runner: openocd
Traceback (most recent call last):
File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
 "__main__", mod_spec)
File "c:\python37\lib\runpy.py", line 85, in _run_code
 exec(code, run_globals)
File "C:\Python37\Scripts\west.exe\__main__.py", line 9, in <module>
File "c:\python37\lib\site-packages\west\_bootstrap\main.py", line 499, in main
 wrap(wrap_argv)
File "c:\python37\lib\site-packages\west\_bootstrap\main.py", line 485, in wrap
 west.main.main(argv)
File "C:\zephyrproject\.west\west\src\west\main.py", line 580, in main
  args.handler(args, unknown)
File "C:\zephyrproject\.west\west\src\west\main.py", line 332, in ext_command_handler
  command.run(*west_parser.parse_known_args(argv))
File "C:\zephyrproject\.west\west\src\west\commands\command.py", line 90, in run
  self.do_run(args, unknown)
File "c:\zephyrproject\zephyr\scripts\west_commands\flash.py", line 32, in do_run
  'ZEPHYR_BOARD_FLASH_RUNNER')
File "C:\zephyrproject\zephyr\scripts/west_commands\run_common.py", line 228, in do_run_common
  runner.run(command_name)
File "C:\zephyrproject\zephyr\scripts/west_commands\runners\core.py", line 407, in run
  self.do_run(command, **kwargs)
File "C:\zephyrproject\zephyr\scripts/west_commands\runners\openocd.py", line 84, in do_run
  self.do_flash(**kwargs)
File "C:\zephyrproject\zephyr\scripts/west_commands\runners\openocd.py", line 116, in do_flash
  self.check_call(cmd)
File "C:\zephyrproject\zephyr\scripts/west_commands\runners\core.py", line 466, in check_call
  subprocess.check_call(cmd)
File "c:\python37\lib\subprocess.py", line 342, in check_call
  retcode = call(*popenargs, **kwargs)
File "c:\python37\lib\subprocess.py", line 323, in call
  with Popen(*popenargs, **kwargs) as p:
File "c:\python37\lib\subprocess.py", line 775, in __init__
  restore_signals, start_new_session)
File "c:\python37\lib\subprocess.py", line 1178, in _execute_child
  startupinfo)
FileNotFoundError: [WinError 2] the specified file could not be found
FAILED: zephyr/cmake/flash/CMakeFiles/flash
cmd.exe /C "cd /D C:\zephyrproject\zephyr\samples\hello_world\build && "C:\ProgramFiles\     
CMake\bin\cmake.exe" -E env C:/Python37/Scripts/west.exe flash --skip-rebuild"
ninja: build stopped: subcommand failed.

Can you find a solution to this problem?

carlescufi commented 5 years ago

@chaos4284 please install OpenOCD for Windows and place it in your PATH.

chaos4284 commented 5 years ago

this issue was confirmed to be caused by a firewall. I am going to closed this issue after confirming more it.

mbolivar commented 5 years ago

this issue was confirmed to be caused by a firewall. I am going to closed this issue after confirming more it.

Thank you for the feedback. If your investigation shows a way we could detect the firewall issue and print a better error message instead of a stack trace, please let us know! Thanks.

chaos4284 commented 5 years ago

Afterward ninja debug, (WUL: Ubuntu 18.04)

[0/1] Debugging nucleo_l476rg
Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-g0b1cbf175-dirty (2019-03-08-20:54)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb: error while loading shared libraries:             
libpython2.7.so.1.0: cannot open shared object file: No such file or directory
Info : The selected transport took over low-level target control. The results might differ compared to     
plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Error: open failed

**ERROR: command exited with status 127: /opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb     
-ex 'target remote :3333' /home/zephyrproject/zephyr/samples/hello_world/build/zephyr/zephyr.elf**

run as "west -v debug --skip-rebuild" for a stack trace
FAILED: zephyr/cmake/flash/CMakeFiles/debug
cd /home/zephyrproject/zephyr/samples/hello_world/build && /home/kwon/cmake-3.13.1-Linux-    
x86_64/bin/cmake -E env /usr/local/bin/west debug --skip-rebuild
ninja: build stopped: subcommand failed.

Afterward ninja debug, (Windows10)

[0/1] Debugging nucleo_l476rg
Using runner: openocd
Open On-Chip Debugger 0.10.0 (2019-02-10) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
GNU gdb (GNU Tools for Arm Embedded CP:r/ozceepshsyroprrosj e7c-t2/z0e1ph8y-rq/2bo-arudpsd/aatrem/)n u8c.l1e.o0_.l42706r1g\8su0pp3o1r5t\-ogpietno
cdC.cofpgy:1r: iEgrhrto r(:C )Ca n2'0t1 8f iFndr beoea rSdo/sftt_wnuacrleeo_ lF4.ocfug
nidn aptrioocned,u rIe n'scc.r
ipLti'c e
ants ef ilGeP L"ve3m+b:e dGdeNd:Us taGrPtLup .vtcelr"s, iloinne  36 3
oatr  flialtee r" C:</hzetpthpy:r/p/rgojneuc.t/ozerpghy/rl/ibcoaerndss/easr/mg/pnulc.lheot_mll4>76
rgT\hsiusp poirts\ opferneoced .scoffgt",w alrinee :1
you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from C:/zephyrproject/zephyr/samples/hello_world/build/zephyr/zephyr.elf...done.
**:3333:  No connection could be made because the target machine actively refused it.**
mbolivar commented 5 years ago

@chaos4284 I guess this means port 3333 is blocked by your firewall; is that right?

If there is a problem with port 3333 but you can use some other port in your firewall, you can use west debug --gdb-port SOME_OTHER_NUMBER instead of ninja debug to pick a value that will work for you.

mbolivar commented 5 years ago

@chaos4284 I guess this means port 3333 is blocked by your firewall; is that right?

Hi @chaos4284, just following up on this.

mbolivar commented 5 years ago

Closing since the submitter says they've figured it out and hasn't replied in the past month.