Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MP1] Add upload tools for MP1: run_arduino_gen.sh and busybox-w32 #47

Merged
merged 5 commits into from Nov 15, 2019

Conversation

kbumsik
Copy link
Contributor

@kbumsik kbumsik commented Oct 22, 2019

In order to make the Arduino firmware works with the coprocessor (Cortex M4) of STM32MP1, I create a new upload tool for the board. There are some motivations to create a new tool:

  • There is no good way to deal with Engineering mode, the flashing mode that you can use ST-Link, since the firmware disappears in the next boot. A new tool is needed to deal with Production mode. See Engineering mode vs Production mode here: https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_development_guidelines

  • There is no way to directly flash the M4 coprocessor using Arduino IDE. The M4 core does not have a flash memory, we can use Engineering Mode to flash through ST-Link but the firmware will disappear right after rebooting to the Distribution mode (aka normal mode). So we need to transfer compiled Arduino firmware binary file to the board and log in to the shell session (either SSH or ST-Link serial) to the MP1 board.

  • We need to input the IP address, username, and password of the MP1 board to transfer the binary via SSH (SCP or SFTP), however, Arduino IDE does not provide an interactive interface to input the SSH information. So users must upload the binary file manually.

  • A script file is needed to manage the binary file in the shell session of the MP1 board.

The new run_arduino_gen.sh is a shell script that produces a copy of the script called run_arduino.sh but with a Arduino binary self-contained. Since run_arduino.sh contains the binary, users doesn't need to transfer a script file and a binary file together but just one run_arduino.sh file. After transferring the script, users can start/stop/install the Arduino firmware.

You can take a look at the README.md below to see how to use it:
https://github.com/kbumsik/Arduino_Core_STM32/tree/stm32mp1/variants/STM32MP157_DK

Also, run_arduino_gen.sh is a script that uses Busybox commands. In order to work it on Windows, we need an executable of busybox compiled for Windows. I copied busybox-w32 from https://frippery.org/busybox/.

The scripts for Windows, Mac, and Linux are identical.


This change is Reviewable

@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 8, 2019

Some typos are fixed and squashed today. The commands remains untouched.

@fpistm
Copy link
Member

fpistm commented Nov 10, 2019

The scripts for Windows, Mac, and Linux are identical.

I wonder if this should not be fine to avoid duplicate it and put it in a single place.

@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 10, 2019

@fpistm There should be no problem. I just couldn't find the appropriate place in this directory organization. I should've asked you about this.

@fpistm
Copy link
Member

fpistm commented Nov 10, 2019

I guess at the root. This would be fine.
And update platform.txt to match new path.

@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 11, 2019

OK, I moved it to root :) Updated platform.txt as well.

@fpistm
Copy link
Member

fpistm commented Nov 12, 2019

OK, I moved it to root :) Updated platform.txt as well.

Thanks this will avoid misalignment across host OS if it is updated.

@fpistm fpistm self-requested a review November 12, 2019 08:05
@fpistm fpistm added this to In progress in STM32duino libraries via automation Nov 12, 2019
@fpistm fpistm added this to the 1.3.2 milestone Nov 12, 2019
run_arduino_gen.sh Show resolved Hide resolved
run_arduino_gen.sh Show resolved Hide resolved
run_arduino_gen.sh Outdated Show resolved Hide resolved
STM32duino libraries automation moved this from In progress to Needs review Nov 13, 2019
STM32duino libraries automation moved this from Needs review to Reviewer approved Nov 14, 2019
@fpistm
Copy link
Member

fpistm commented Nov 14, 2019

@kbumsik
I think, it should be fine to add in the generated script the name of the built sketch:
Ex in platform.txt:
tools.remoteproc_gen.upload.pattern="{busybox}" sh "{path}/{script}" generate "{build.path}/{build.project_name}.elf" "{build.path}/run_arduino_{build.project_name}.sh"

Then it will be more easiest for end user.
For service name (systemd), kept the generic "run_arduino.sh" name (currently hardcoded so this seems does not need to be updated).

run_arduino_gen.sh Show resolved Hide resolved
run_arduino_gen.sh Outdated Show resolved Hide resolved
run_arduino_gen.sh Show resolved Hide resolved
@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 14, 2019

run_arduino_{build.project_name}.sh sounds better to me too. Also change <Arduino build output path>/run_arduino.sh to <Arduino build output path>/run_arduino_<your project name>.sh accordingly in the documentation?

@fpistm
Copy link
Member

fpistm commented Nov 14, 2019

run_arduino_{build.project_name}.sh sounds better to me too. Also change <Arduino build output path>/run_arduino.sh to <Arduino build output path>/run_arduino_<your project name>.sh accordingly in the documentation?

Right. Missed that. Good catch 😉

@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 15, 2019

tools.remoteproc_gen.upload.pattern="{busybox}" sh "{path}/{script}" generate "{build.path}/{build.project_name}.elf" "{build.path}/run_arduino_{build.project_name}.sh"

@fpistm I just tested it but build.project_name includes .ino. So the output looks like run_arduino_Blink.ino.sh. Do you know a variable without .ino?

@fpistm
Copy link
Member

fpistm commented Nov 15, 2019

tools.remoteproc_gen.upload.pattern="{busybox}" sh "{path}/{script}" generate "{build.path}/{build.project_name}.elf" "{build.path}/run_arduino_{build.project_name}.sh"

@fpistm I just tested it but build.project_name includes .ino. So the output looks like run_arduino_Blink.ino.sh. Do you know a variable without .ino?

@kbumsik unfortunately no. Using sed it could be removed, if also available in the busybox.

@kbumsik
Copy link
Contributor Author

kbumsik commented Nov 15, 2019

@fpistm sed is included in busybox, but how run in-line script or something for sed in platform.txt?

@fpistm
Copy link
Member

fpistm commented Nov 15, 2019

I think in the generate function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants