-
Notifications
You must be signed in to change notification settings - Fork 1
FEATURE: Added arduino CLI support #15
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
d126898
3adfa7e
b2b31d8
0cd0736
0f8b7aa
6936b1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||
PRJ_DIR = $(realpath .) | ||||||
|
||||||
# ============================================================================= ARGS | ||||||
PATH_SKETCH := $(PRJ_DIR)/clock_setup/clock_setup.ino | ||||||
|
||||||
PORT := /dev/ttyACM0 | ||||||
|
||||||
FILE_CONFIG := arduino-cli.yaml | ||||||
BOARD_CORE := WCH:ch32v | ||||||
BOARD_LIST := WCH | ||||||
FQBN := WCH:ch32v:CH32V00x_EVT | ||||||
|
||||||
# ============================================================================= TARGETS | ||||||
|
||||||
# setup and install arduino CLI | ||||||
setup-arduino-cli: | ||||||
@ echo " " | ||||||
[ -d ~/arduino_cli ] || mkdir -p ~/arduino_cli; \ | ||||||
cd ~/arduino_cli; \ | ||||||
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh; \ | ||||||
echo "========== Verifying installation..."; \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this layout a standard from somewhere? If not, what about something like this (also for all others and also the comments):
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this formatting? This is also used on multiple occasions |
||||||
source $(HOME)/.bashrc; \ | ||||||
which arduino-cli; \ | ||||||
arduino-cli version | ||||||
|
||||||
# setup board files for CH32V003 on arudino | ||||||
setup-board-files: | ||||||
@ echo " " | ||||||
@ echo "==================== Creating board config file" | ||||||
arduino-cli config init && \ | ||||||
@ echo "==================== Copy file to config folder"; \ | ||||||
[ -d $(HOME)/.arduino15 ] || mkdir -p $(HOME)/.arduino15; \ | ||||||
cp -rv ./$(FILE_CONFIG) $(HOME)/.arduino15/$(FILE_CONFIG) && \ | ||||||
@ echo "==================== Update the core index"; \ | ||||||
arduino-cli core update-index && \ | ||||||
@ echo "==================== Search for WCH boards"; \ | ||||||
arduino-cli core search wch && \ | ||||||
@ echo "==================== Install the core"; \ | ||||||
arduino-cli core install $(BOARD_CORE) && \ | ||||||
@ echo "==================== Verify installation"; \ | ||||||
arduino-cli core list && \ | ||||||
@ echo "==================== List all WCH boards"; \ | ||||||
arduino-cli board listall $(BOARD_LIST) | ||||||
|
||||||
# show all connected boards/chips via USB | ||||||
list-boards: | ||||||
@ echo " " | ||||||
@ echo "==================== List connected boards"; \ | ||||||
IAmMarcelJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
arduino-cli board list && \ | ||||||
@ echo "==================== List Ch32V boards available"; \ | ||||||
IAmMarcelJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
arduino-cli board listall | grep CH32 | ||||||
|
||||||
# compile the arduino sketch for the chip | ||||||
compile: | ||||||
@ echo " " | ||||||
@ echo "==================== Compiling sketch" | ||||||
arduino-cli compile --fqbn $(FQBN) $(PATH_SKETCH) | ||||||
|
||||||
# upload the sketch to the board | ||||||
upload: | ||||||
@ echo " " | ||||||
@ echo "==================== Uploading sketch" | ||||||
arduino-cli upload $(PATH_SKETCH) -p $(PORT) --fqbn $(FQBN) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||
# How to setup and upload code | ||||||
|
||||||
To flash the firmware for configuring the PLL chip to compatible MCUs we will be using [Arduino-CLI](https://github.com/arduino/arduino-cli). | ||||||
IAmMarcelJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
## Procedure | ||||||
|
||||||
### Prerequisite | ||||||
|
||||||
- Add the following line in your `.bashrc` or `.zshrc`. | ||||||
```bash | ||||||
export PATH=$HOME/arduino_cli/bin:$PATH | ||||||
``` | ||||||
- Make sure to source your `.bashrc` or `.zshrc` after updating `$PATH`. | ||||||
|
||||||
- Install `libhidapi-hidraw0` library for USB serial communication. | ||||||
```bash | ||||||
# Ubuntu/Debian | ||||||
sudo apt update | ||||||
sudo apt install libhidapi-hidraw0 | ||||||
``` | ||||||
|
||||||
### Install Arduino CLI | ||||||
- Move to directory `./software/clock_setup_using_arduino_code` which contains | ||||||
the Makefile required for setup, compilation and uploading the sketch. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
These files are already in this directory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still in the latest commits |
||||||
- Run `make setup-arduino-cli` which will install `arduino-cli`. | ||||||
|
||||||
### Install Board Files | ||||||
- Now we need to setup and add the board support files for our CH32 EVT chips which can be found [here](https://github.com/openwch/arduino_core_ch32). | ||||||
- Run `make setup-board-files` which will download, search and install all board files necessary. | ||||||
|
||||||
### Compile and Upload | ||||||
- Now connect the chip using the WCH-Debugger Link and run the following command: | ||||||
```bash | ||||||
# show all connected boards/chips via USB | ||||||
make list-boards | ||||||
``` | ||||||
- Make sure to check if Port value e.g. `/dev/ttyACM0` is the same as in the `Makefile`. If not, update it accordingly. | ||||||
IAmMarcelJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- To compile the sketch run: | ||||||
```bash | ||||||
make compile | ||||||
``` | ||||||
- To upload the sketch on the chip run: | ||||||
```bash | ||||||
make upload | ||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
board_manager: | ||
additional_urls: | ||
- https://github.com/openwch/board_manager_files/raw/main/package_ch32v_index.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably add a prompt for changing the installation directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also see nothing that implements this. Any thoughts?