Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions boards.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
menu.debug=Debug
menu.link_mode=Link mode
menu.flash_mode=Flash mode
menu.wait_linux_boot=Startup mode

##########################################################################################
Expand Down Expand Up @@ -638,13 +637,11 @@ unoq.menu.link_mode.static=Static
unoq.menu.link_mode.static.build.link_mode=static
unoq.menu.link_mode.static.upload.extension=bin-zsk.bin

unoq.menu.flash_mode.flash=Flash
unoq.menu.flash_mode.flash.openocd_cfg=flash_sketch.cfg
unoq.menu.flash_mode.ram=RAM
unoq.menu.flash_mode.ram.openocd_cfg=flash_sketch_ram.cfg
unoq.menu.wait_linux_boot.yes=Wait for Linux
unoq.menu.wait_linux_boot.no=Immediate
unoq.menu.wait_linux_boot.no.build.boot_mode=immediate
unoq.menu.wait_linux_boot.app=Wait for App
unoq.menu.wait_linux_boot.app.build.boot_mode=app

unoq.build.zephyr_target=arduino_uno_q
unoq.build.zephyr_args=
Expand All @@ -656,6 +653,8 @@ unoq.build.fpu=-mfpu=fpv5-sp-d16
unoq.build.architecture=cortex-m33
unoq.compiler.zephyr.arch.define=

unoq.openocd_cfg=flash_sketch.cfg

unoq.build.float-abi=-mfloat-abi=hard
unoq.build.extra_flags=
unoq.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
Expand Down
4 changes: 4 additions & 0 deletions extra/zephyr-sketch-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func main() {
var output = flag.String("output", "", "Output to a specific file (default: add -zsk.bin suffix)")
var debug = flag.Bool("debug", false, "Enable debugging mode")
var immediate = flag.Bool("immediate", false, "Start sketch immediately [UNO Q]")
var wait_for_app = flag.Bool("wait_for_app", false, "Wait for the app to start [UNO Q]")
var linked = flag.Bool("prelinked", false, "Provided file has already been linked to Zephyr")
var force = flag.Bool("force", false, "Ignore safety checks and overwrite the header")
var add_header = flag.Bool("add_header", false, "Add space for the header to the file")
Expand Down Expand Up @@ -63,6 +64,9 @@ func main() {
if *immediate {
header.flags |= 0x04
}
if *wait_for_app {
header.flags |= 0x08
}

var bytes = make([]byte, 9)
_, err = binary.Encode(bytes, binary.LittleEndian, header)
Expand Down
34 changes: 11 additions & 23 deletions loader/main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright (C) 2024 Arduino SA
*
Expand Down Expand Up @@ -34,9 +34,10 @@
uint8_t flags; // @ 0x0e
} __attribute__((packed));

#define SKETCH_FLAG_DEBUG 0x01
#define SKETCH_FLAG_LINKED 0x02
#define SKETCH_FLAG_IMMEDIATE 0x04
#define SKETCH_FLAG_DEBUG 0x01
#define SKETCH_FLAG_LINKED 0x02
#define SKETCH_FLAG_IMMEDIATE 0x04
#define SKETCH_FLAG_WAIT_FOR_APP 0x08

#define SKETCH_RAM_BUFFER_LEN 131072

Expand Down Expand Up @@ -179,17 +180,6 @@

gpio_pin_configure_dt(&spec, GPIO_INPUT | GPIO_PULL_DOWN);
k_sleep(K_MSEC(200));
uint8_t *ram_firmware = NULL;
uint32_t *ram_start = (uint32_t *)0x20000000;
if (!sketch_valid) {
ram_firmware = (uint8_t *)malloc(SKETCH_RAM_BUFFER_LEN);
if (!ram_firmware) {
printk("Failed to allocate RAM for firmware\n");
return -ENOMEM;
}
memset(ram_firmware, 0, SKETCH_RAM_BUFFER_LEN);
*ram_start = (uint32_t)&ram_firmware[0];
}
if (gpio_pin_get_dt(&spec) == 0) {
matrixBegin();
matrixSetGrayscaleBits(8);
Expand All @@ -202,15 +192,13 @@
k_sleep(K_MSEC(10));
matrixEnd();
}
while (!sketch_valid) {
__asm__("bkpt");
// poll the first bytes, if filled try to use them for booting
sketch_hdr = (struct sketch_header_v1 *)(ram_firmware + 7);
if (sketch_hdr->ver == 0x1 && sketch_hdr->magic == 0x2341) {
// Found valid data, use it for booting
base_addr = (uintptr_t)ram_firmware;
*ram_start = 0;
sketch_valid = true;
if (sketch_hdr->flags & SKETCH_FLAG_WAIT_FOR_APP) {
// wait for another pin toggle
while (gpio_pin_get_dt(&spec) != 0) {
k_sleep(K_MSEC(10));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make this more robust by setting a max length of the LOW state, e.g., 200ms?

while (gpio_pin_get_dt(&spec) != 1) {
k_sleep(K_MSEC(10));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ build.zsk_args.debug=
build.zsk_args.mode-dynamic=
build.zsk_args.mode-static=-prelinked
build.zsk_args.startup-mode-wait=
build.zsk_args.startup-mode-app=-wait_for_app
build.zsk_args.startup-mode-immediate=-immediate

# These can be overridden in platform.local.txt
Expand Down
Loading