Skip to content

Commit b1cdfa0

Browse files
authored
Merge pull request #210 from arduino/unoq
board: Add support for UNO Q
2 parents 1b42661 + 10c342a commit b1cdfa0

27 files changed

+12359
-6
lines changed

.github/workflows/package_core.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ jobs:
2424
2525
- uses: actions/checkout@v4
2626
with:
27+
submodules: 'recursive'
2728
fetch-depth: 0
2829
persist-credentials: false
30+
fetch-tags: true
2931

3032
- name: Initialize Zephyr environment
3133
run: |

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "libraries/Arduino_RPCLite"]
2+
path = libraries/Arduino_RPCLite
3+
url = git@github.com:arduino-libraries/Arduino_RPCLite.git
4+
[submodule "libraries/Arduino_RouterBridge"]
5+
path = libraries/Arduino_RouterBridge
6+
url = git@github.com:arduino-libraries/Arduino_RouterBridge.git

boards.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,56 @@ opta.debug.cortex-debug.custom.request=attach
521521
opta.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM7.svd
522522

523523
##############################################################################################################
524+
525+
unoq.name=Arduino UNO Q
526+
unoq.build.core=arduino
527+
unoq.build.crossprefix=arm-zephyr-eabi-
528+
unoq.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
529+
530+
unoq.menu.link_mode.dynamic=Dynamic
531+
unoq.menu.link_mode.static=Static
532+
unoq.menu.link_mode.static.build.link_mode=static
533+
unoq.menu.link_mode.static.upload.extension=bin-zsk.bin
534+
535+
unoq.build.zephyr_target=arduino_uno_q
536+
unoq.build.zephyr_args=
537+
unoq.build.variant=arduino_uno_q_stm32u585xx
538+
unoq.build.mcu=cortex-m33
539+
unoq.build.fpu=-mfpu=fpv5-sp-d16
540+
unoq.build.architecture=cortex-m33
541+
unoq.compiler.zephyr.arch.define=
542+
543+
unoq.build.float-abi=-mfloat-abi=hard
544+
unoq.build.extra_flags=
545+
unoq.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
546+
unoq.build.board=UNO_Q
547+
unoq.build.zephyr_hals=hal_stm32
548+
unoq.compiler.zephyr.arch.define=
549+
unoq.compiler.zephyr=
550+
unoq.vid.0=0x2341
551+
unoq.pid.0=0x0078
552+
unoq.upload_port.0.vid=0x2341
553+
unoq.upload_port.0.pid=0x0078
554+
unoq.upload.address=0x80F0000
555+
unoq.upload.target=stm32u585zitxq
556+
557+
unoq.upload.tool=remoteocd
558+
unoq.upload.tool.default=remoteocd
559+
unoq.upload.tool.network=remoteocd_network
560+
unoq.upload.protocol=
561+
unoq.upload.transport=
562+
unoq.upload.vid=0x2341
563+
unoq.upload.pid=0x0078
564+
unoq.upload.interface=0
565+
unoq.upload.use_1200bps_touch=false
566+
unoq.upload.wait_for_upload_port=false
567+
unoq.upload.native_usb=true
568+
unoq.upload.maximum_size=1966080
569+
unoq.upload.maximum_data_size=523624
570+
571+
unoq.bootloader.tool=remoteocd
572+
unoq.bootloader.tool.default=remoteocd
573+
unoq.bootloader.file=zephyr-{build.variant}.elf
574+
unoq.bootloader.target=stm32u585zitxq
575+
576+
##########################################################################################

cores/arduino/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#undef DIGITAL_PIN_CHECK_UNIQUE
3838
#endif
3939

40+
// Helper macro to get Arduino pin number from device tree alias
41+
#define DIGITAL_PIN_GPIOS_FIND_NODE(node) \
42+
DIGITAL_PIN_GPIOS_FIND_PIN(DT_REG_ADDR(DT_PHANDLE_BY_IDX(node, gpios, 0)), \
43+
DT_PHA_BY_IDX(node, gpios, 0, pin))
44+
4045
#ifndef LED_BUILTIN
4146

4247
/* Return the index of it if matched, oterwise return 0 */

cores/arduino/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ void start_static_threads();
1919
void __attribute__((weak)) initVariant(void) {
2020
}
2121

22+
// This function can be overwriten by one library.
23+
void __attribute__((weak)) __loopHook(void) {
24+
}
25+
2226
int main(void) {
2327
#if (DT_NODE_HAS_PROP(DT_PATH(zephyr_user), cdc_acm) && \
2428
(CONFIG_USB_CDC_ACM || CONFIG_USBD_CDC_ACM_CLASS))
@@ -39,6 +43,7 @@ int main(void) {
3943
// DT_NODE_HAS_PROP(DT_PATH(zephyr_user), serials)
4044
if (arduino::serialEventRun) arduino::serialEventRun();
4145
#endif
46+
__loopHook();
4247
}
4348

4449
return 0;
@@ -94,7 +99,7 @@ extern "C" __attribute__((section(".entry_point"), used)) void entry_point(struc
9499
printk("Sketch Heap start: %p, size %p\n", &kheap_llext_heap, &kheap_llext_heap_size);
95100

96101
memcpy(&_sdata, &_sidata, (&_edata - &_sdata) * sizeof(uint32_t));
97-
memset(&_sbss, 0, &_ebss - &_sbss);
102+
memset(&_sbss, 0, (&_ebss - &_sbss) * sizeof(uint32_t));
98103
__libc_init_array();
99104
main();
100105
}

cores/arduino/zephyrCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void analogWrite(enum dacPins dacName, int value) {
353353

354354
#ifdef CONFIG_ADC
355355

356-
void analogReference(uint8_t mode) {
356+
void __attribute__((weak)) analogReference(uint8_t mode) {
357357
/*
358358
* The Arduino API not clearly defined what means of
359359
* the mode argument of analogReference().

extra/install_remoteocd.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
REPO_URL="https://github.com/bcmi-labs/orchestrator.git"
4+
BRANCH_NAME="main"
5+
6+
set -xe
7+
8+
TMP_DIR=$(mktemp -d)
9+
10+
# pull the repo
11+
git clone "$REPO_URL" "$TMP_DIR"
12+
cd "$TMP_DIR"
13+
git checkout "$BRANCH_NAME"
14+
15+
# compile remoteocd
16+
go build -o build/remoteocd ./cmd/remoteocd
17+
18+
# move into arduino tools
19+
TARGET_PATH=$(arduino-cli config get directories.data)/packages/arduino/tools/remoteocd/0.0.1
20+
mkdir -p "$TARGET_PATH"
21+
cp build/remoteocd "$TARGET_PATH"
22+
23+
rm -rf "$TMP_DIR"
24+
25+
echo "remoteocd is in $TARGET_PATH/remoteocd"

extra/zephyr-core-template.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
},
3939
{
4040
"name": "NXP FRDM RW612"
41+
},
42+
{
43+
"name": "Arduino UNO Q"
4144
}
4245
],
4346
"toolsDependencies": [
@@ -65,6 +68,16 @@
6568
"packager": "arduino",
6669
"name": "sync-zephyr-artifacts",
6770
"version": "0.1.0"
71+
},
72+
{
73+
"packager": "arduino",
74+
"name": "adb",
75+
"version": "32.0.0"
76+
},
77+
{
78+
"packager": "arduino",
79+
"name": "remoteocd",
80+
"version": "0.0.3-rc.2"
6881
}
6982
]
7083
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#include "ArduinoGraphics.h"
2+
#include "Arduino_LED_Matrix.h"
3+
4+
Arduino_LED_Matrix matrix;
5+
6+
void setup() {
7+
// put your setup code here, to run once:
8+
matrix.begin();
9+
matrix.textFont(Font_5x7);
10+
matrix.textScrollSpeed(100);
11+
matrix.clear();
12+
Serial.begin(115200);
13+
}
14+
15+
uint8_t shades[104] = {
16+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
18+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
20+
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
21+
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
22+
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
23+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
24+
};
25+
26+
const uint32_t animation[][5] = {
27+
{ 0x38022020,
28+
0x810408a0,
29+
0x2200e800,
30+
0x20000000,
31+
66 },
32+
{ 0x1c011010,
33+
0x40820450,
34+
0x11007400,
35+
0x10000000,
36+
66 },
37+
{ 0x0e008808,
38+
0x20410228,
39+
0x08803a00,
40+
0x08000000,
41+
66 },
42+
{ 0x07004404,
43+
0x10208114,
44+
0x04401d00,
45+
0x04000000,
46+
66 },
47+
{ 0x03802202,
48+
0x0810408a,
49+
0x02200e80,
50+
0x02000000,
51+
66 },
52+
{ 0x01c01101,
53+
0x04082045,
54+
0x01100740,
55+
0x01000000,
56+
66 },
57+
{ 0x00e00880,
58+
0x82041022,
59+
0x808803a0,
60+
0x00000000,
61+
66 },
62+
{ 0x00700440,
63+
0x40020011,
64+
0x004401c0,
65+
0x00000000,
66+
66 },
67+
{ 0x00380200,
68+
0x20010008,
69+
0x802000e0,
70+
0x00000000,
71+
66 },
72+
{ 0x00180100,
73+
0x10008004,
74+
0x00100060,
75+
0x00000000,
76+
66 },
77+
{ 0x00080080,
78+
0x08004002,
79+
0x00080020,
80+
0x00000000,
81+
66 },
82+
{ 0x00000040,
83+
0x04002001,
84+
0x00040000,
85+
0x00000000,
86+
66 },
87+
{ 0x00000000,
88+
0x02001000,
89+
0x80000000,
90+
0x00000000,
91+
66 },
92+
{ 0x00000000,
93+
0x00000000,
94+
0x00000000,
95+
0x00000000,
96+
66 }
97+
};
98+
99+
void loop() {
100+
// Roll a string using ArduinoGraphics
101+
matrix.beginText(0, 0, 127, 0, 0); // X, Y, then R, G, B
102+
matrix.print(" arduino.cc/uno-q ");
103+
matrix.endText(SCROLL_LEFT);
104+
delay(1000);
105+
// Draw shades
106+
matrix.setGrayscaleBits(3);
107+
matrix.draw(shades);
108+
delay(1000);
109+
matrix.clear();
110+
// Play an animation
111+
matrix.loadSequence(animation);
112+
for (int i = 0; i < 10; i++) {
113+
matrix.playSequence();
114+
}
115+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "bootanimation.h"
2+
#include "ArduinoGraphics.h"
3+
#include "Arduino_LED_Matrix.h"
4+
#include <zephyr/storage/flash_map.h>
5+
6+
Arduino_LED_Matrix matrix;
7+
8+
bool ok = false;
9+
10+
void setup() {
11+
12+
Serial.begin(115200);
13+
matrix.begin();
14+
matrix.textFont(Font_5x7);
15+
matrix.setGrayscaleBits(8);
16+
17+
// Before flashing, show the animation
18+
for (int i = 0; i < 2; i++) {
19+
matrix.playVideo(bootanimation.buf_loop, bootanimation.len_loop);
20+
}
21+
matrix.playVideo((uint8_t*)(bootanimation.buf_loop + bootanimation.len_loop), bootanimation.len_end);
22+
23+
const struct flash_area *fa;
24+
int rc;
25+
rc = flash_area_open(FIXED_PARTITION_ID(bootanimation), &fa);
26+
if (rc) {
27+
return;
28+
}
29+
30+
// flash the bootanimation header
31+
rc = flash_area_erase(fa, 0, fa->fa_size);
32+
if (rc) {
33+
return;
34+
}
35+
int header_len = sizeof(bootanimation) - sizeof(char*);
36+
rc = flash_area_write(fa, 0, &bootanimation, header_len);
37+
if (rc) {
38+
return;
39+
}
40+
rc = flash_area_write(fa, header_len, bootanimation.buf_loop, bootanimation.len_loop + bootanimation.len_end);
41+
if (rc) {
42+
return;
43+
}
44+
uint32_t flash_area[256];
45+
flash_area_read(fa, 0, flash_area, 256);
46+
Serial.println(flash_area[0], HEX);
47+
Serial.println(flash_area[1], HEX);
48+
Serial.println(flash_area[2], HEX);
49+
Serial.println(flash_area[3], HEX);
50+
Serial.println(flash_area[4], HEX);
51+
Serial.println(flash_area[5], HEX);
52+
ok = true;
53+
}
54+
55+
void loop() {
56+
matrix.beginText(0, 0, 127, 0, 0); // X, Y, then R, G, B
57+
if (ok) {
58+
matrix.print("OK :)");
59+
} else {
60+
matrix.print("KO :(");
61+
}
62+
matrix.endText();
63+
}

0 commit comments

Comments
 (0)