Skip to content

Arduino Cli is not working on rpi zero w.  #755

Closed
@raj-priyanshu

Description

@raj-priyanshu

Bug Report

This issue is already discussed before. here, #340
But, It's old Arduino-CLI version (0.4.0) and it is not able to find the board(STM32) connected to it. So I tried arm7 build and it is able to find the board but give the unknown in board name, it can compile successfully it but give some memory error when I trying to upload it.

pi@raspberrypi:~ $ ./arduino-cli board list
Port               Type              Board Name       FQBN Core
/dev/ttyAMA0       Serial Port       Unknown
/dev/ttyS0         Serial Port       Unknown
pi@raspberrypi:~ $ ./arduino-cli upload -p /dev/ttyS0 --fqbn stm32duino:STM32F1:genericSTM32F103C $HOME/Arduino/test
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x385c50]

goroutine 1 [running]:
github.com/arduino/go-paths-helper.(*Path).String(...)
	/github/home/go/pkg/mod/github.com/arduino/go-paths-helper@v1.0.1/paths.go:470
github.com/arduino/arduino-cli/arduino/cores.(*ToolRelease).RuntimeProperties(0x2e67760, 0x4)
	/__w/arduino-cli/arduino-cli/arduino/cores/tools.go:136 +0x7c
github.com/arduino/arduino-cli/commands/upload.Upload(0x914bb8, 0x2c2a078, 0x48a3e88, 0x90d358, 0x2c100e0, 0x90d358, 0x2c100e8, 0x60040c, 0x2c8f4f0, 0x2d46540)
	/__w/arduino-cli/arduino-cli/commands/upload/upload.go:128 +0x6d0
github.com/arduino/arduino-cli/cli/upload.run(0x2d3c140, 0x2c67e30, 0x1, 0x5)
	/__w/arduino-cli/arduino-cli/cli/upload/upload.go:73 +0x180
github.com/spf13/cobra.(*Command).execute(0x2d3c140, 0x2c67e00, 0x5, 0x6, 0x2d3c140, 0x2c67e00)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x1f4
github.com/spf13/cobra.(*Command).ExecuteC(0xdfb388, 0x42754, 0x0, 0x2c000e0)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x230
github.com/spf13/cobra.(*Command).Execute(...)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
	/__w/arduino-cli/arduino-cli/main.go:26 +0x20

Activity

rsora

rsora commented on Jun 22, 2020

@rsora
Contributor

Hi @raj-priyanshu,
Thanks for the Heads up!
Can you please try with the latest release for ARMv6
https://github.com/arduino/arduino-cli/releases/download/0.11.0/arduino-cli_0.11.0_Linux_ARMv6.tar.gz
and tell us if you get errors?

Thanks!

raj-priyanshu

raj-priyanshu commented on Jun 29, 2020

@raj-priyanshu
Author

still getting the similar problem. i am connecting the board with gpio serial and expecting only /dev/ttyS0 and board name but the output is as follow.
pi@raspberrypi:~ $ ./arduino-cli board list
Port Type Board Name FQBN Core
/dev/ttyAMA0 Serial Port Unknown
/dev/ttyS0 Serial Port Unknown
Edit: 1. I am getting the above output even without connecting the board.
2. I can compile a test sketch successfully by '$./arduino-cli compile -v -b stm32duino:STM32F1:genericSTM32F103C $HOME/Arduino/test'
3. I tried to upload the sketch anyway and got error for both port [/dev/ttyAMA0 and /dev/ttytS0.
4. similar kind of problem discuss here https://github.com//issues/435 and I tried what they discussed there but not get succeded.

rsora

rsora commented on Jun 29, 2020

@rsora
Contributor

@raj-priyanshu Can you please confirm that you installed the stm32duino:STM32F1 core?
Can you please run a arduino-cli core list and post here the output you get?

Thanks!

raj-priyanshu

raj-priyanshu commented on Jun 29, 2020

@raj-priyanshu
Author

@rsora
here it is
pi@raspberrypi:~ $ ./arduino-cli core list
ID Installed Latest Name
stm32duino:STM32F1 2019.2.28 2019.2.28 STM32F1xx/GD32F1xx boards

Edit: I am still confused about this. -> I am getting this output even without connecting the board. here is the output without the board connected.
pi@raspberrypi:~ $ ./arduino-cli board list
Port Type Board Name FQBN Core
/dev/ttyAMA0 Serial Port Unknown
/dev/ttyS0 Serial Port Unknown

rsora

rsora commented on Jun 29, 2020

@rsora
Contributor

I'll ask to @per1234 to chime in as I'm not an expert in the STM32F1 chip, from CLI side it seems to me that everything was done correctly by the user.

Maybe this particular board requires some additional config parameters to pass via FQBN?

self-assigned this
on Jul 1, 2020
ubidefeo

ubidefeo commented on Jul 1, 2020

@ubidefeo

hi @raj-priyanshu
Sorry for the late reply on this, I've assigned the issue to myself in order to take some stuff off of @per1234 's plate, and because this kind of investigation is fun.

Let me share with you what Per found out and what I'm up to in order to resolve the issue and point you in the right direction.
I don't have a Blue Pill handy now, and modifying an ST-Link V2 has failed miserably, but I'll have one in house tomorrow to test.

I brought myself up to speed with STM32duino and setup a Pi Zero with Arduino-CLI which works well, and as soon as I have an F103 with bootloader I'll attempt what you are having problems with.

Here's what Per found out and observed in our conversation based on you referring to GPIO serial on the Pi.:

  • you are trying to upload code to the STM32 via the serial port connected to the chip A9 and A10
  • you use Raspberry Pi's on-board GPIO UART pins 15 (TXD) and 14 (RXD) respectively
  • you have been using this guide
  • you seem to use an outdated core (2019.2.28) vs the (2020.6.20)

The first outcome is not seeing a board name, which is normal because boards can be identified solely from their USB VID:PID pair, while a serial port is just a serial port.
Per observed that uploading via serial port will require a parameter to be added as extra configuration for the board, and such parameter is upload_method=serialMethod, otherwise the core defaults to DFUUploadMethod and that won't work over serial.

As I gathered more information I also found out that you'll need the pins BOOT0 set to HIGH and BOOT1 set to LOW in order to be able to upload a new firmware via the Maple bootloader.

My suggestion is that you begin with making sure BOOT0 and BOOT1 are properly configured and that you add the upload_method parameter to your fqbn
Try the following

./arduino-cli upload -p /dev/ttyS0 --fqbn stm32duino:STM32F1:genericSTM32F103C:upload_method=serialMethod $HOME/Arduino/test

and let me know.
I'll test the same and let you know, but if you succeed, please, report back to us :)

raj-priyanshu

raj-priyanshu commented on Jul 1, 2020

@raj-priyanshu
Author

Hi @ubidefeo, Thanks for covering the issue

Here are the steps I did for testing:

  1. I install the new version Arduino-CLI Version: 0.11.0 Commit: 0296f4d provided by rsora in this thread.
  2. I add this URL:
    http://dan.drown.org/stm32duino/package_STM32duino_index.json
    
  3. I install the STM32F103 board with this command:
    $ ./arduino-cli core install stm32duino:STM32F1
    
  4. I connect A9 and A10 of STM 32 with Raspberry pi's 15 and 14 pins respectively.
  5. Change boot mode as boot0 at 1 and boot1 at 0.
  6. Press the reset button.
  7. upload the code by:
    $ ./arduino-cli upload -p /dev/ttyS0 --fqbn stm32duino:STM32F1:genericSTM32F103C:upload_method=serialMethod /home/pi/MyFirstSketch
    

I got this result:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x388a2c]

goroutine 1 [running]:
github.com/arduino/go-paths-helper.(*Path).String(...)
/github/home/go/pkg/mod/github.com/arduino/go-paths-helper@v1.2.0/paths.go:482
github.com/arduino/arduino-cli/arduino/cores.(*ToolRelease).RuntimeProperties(0x1bcde20, 0x4)
/__w/arduino-cli/arduino-cli/arduino/cores/tools.go:136 +0x7c
github.com/arduino/arduino-cli/commands/upload.runProgramAction(0x19d7380, 0x3135eb0, 0x0, 0x0, 0xbec5e678, 0x3f, 0xbec5e666, 0xa, 0x0, 0x0, ...)
/__w/arduino-cli/arduino-cli/commands/upload/upload.go:196 +0x850
github.com/arduino/arduino-cli/commands/upload.Upload(0x99cd48, 0x182a078, 0x34f3e30, 0x994be0, 0x18100e0, 0x994be0, 0x18100e8, 0x6, 0xa51031a5, 0x396c74)
/__w/arduino-cli/arduino-cli/commands/upload/upload.go:56 +0x2ac
github.com/arduino/arduino-cli/cli/upload.run(0x19e4c60, 0x19d0630, 0x1, 0x5)
/__w/arduino-cli/arduino-cli/cli/upload/upload.go:109 +0x1ec
github.com/spf13/cobra.(*Command).execute(0x19e4c60, 0x19d0600, 0x5, 0x6, 0x19e4c60, 0x19d0600)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x1f4
github.com/spf13/cobra.(*Command).ExecuteC(0x1895a20, 0x0, 0x0, 0x18000e0)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x26c
github.com/spf13/cobra.(*Command).Execute(...)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
/__w/arduino-cli/arduino-cli/main.go:31 +0x24

I tried with usb to ttl serial cable on Ubuntu 20.04 and successfully uploaded the code.

ubidefeo

ubidefeo commented on Jul 1, 2020

@ubidefeo

hey @raj-priyanshu
thank you for giving it a shot.
bummer!

I have failed to hack my ST-Link into a bare board, but tomorrow I'm receiving a blue pill.

I'm concerned by this message
Filter on vendor = 0x1eaf product = 0x0003 No DFU capable USB device found Waiting for /dev/ttyUSB0 serial...Done because it means that it's still trying DFU upload.
I look forward to trying this out.

Keep you posted, and thank you for helping us squash some bugs 🙏🏼

raj-priyanshu

raj-priyanshu commented on Jul 1, 2020

@raj-priyanshu
Author

Hi @ubidefeo...
I forgot to mention... the last one (STEP 9) I tried on my computer and not on raspberry pi... Also, I was making some mistake in the uploading process. So, I found that and got a successful upload on Bluepill. :)
Since the same version of Arduino-CLI is working on my computer (Linux x64) I think it is more like build issue for arm6.

ubidefeo

ubidefeo commented on Jul 2, 2020

@ubidefeo

That is an interesting turn of events, but before blaming the ARMv6 version I'd like to look at why it shouldn't work on the Pi.
Forgive me for asking, but even 15 years later I sometimes make this mistake myself:
Have you connected Blue Pill this way?

Blue Pill direction RPi
RX < TXD
TX > RXD
GND - GND
3V3 - 3V3
raj-priyanshu

raj-priyanshu commented on Jul 2, 2020

@raj-priyanshu
Author

Hi @ubidefeo,
Yes, apart from that I make a pcb for this, Where rpi communicating to stm32 over serial connection and both already able to communicate properly. I wanted some cli solutions so that I could easly program the arm over ssh connection and I found Arduino-cli could be helful.
To be make sure it is not the problem with my pcb I already checked the same connection on breadboard first. And then tried to flash.so, I am very sure about connection side nothing is wrong.
Ps.- also found that some basic features will be helpful with Arduino cli so once this issue is covered I will put some feature request.

ubidefeo

ubidefeo commented on Jul 2, 2020

@ubidefeo

All right, I'm happy you picked our CLI for your needs and I'll further investigate this with the team.
I can't wait for my Blue Pill to arrive and get cracking :)

Please feel free to propose features, we're at a phase of the project in which we can still shape a lot and you'll see more releases coming out as we add/remove/adjust workflows based on users' needs

Thank you for helping hunt this one down for now
u.

21 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @cmaglie@ubidefeo@rsora@raj-priyanshu

    Issue actions

      Arduino Cli is not working on rpi zero w. · Issue #755 · arduino/arduino-cli