diff --git a/Cargo.toml b/Cargo.toml index 866cfe0..15a0ab4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ codegen-units = 1 debug = 2 debug-assertions = true # <- incremental = false -# This is problematic for stepping.. -# opt-level = 'z' # <- +# 1 instead of 0, the flashloader is too larger otherwise.. +# opt-level = 1 # <- overflow-checks = true # <- # cargo build/run --release diff --git a/bootloader/Cargo.toml b/bootloader/Cargo.toml index e942422..a2e3242 100644 --- a/bootloader/Cargo.toml +++ b/bootloader/Cargo.toml @@ -7,8 +7,6 @@ edition = "2021" cortex-m = "0.7" cortex-m-rt = "0.7" embedded-hal = "1" -embedded-hal-bus = "0.2" -dummy-pin = "1" panic-rtt-target = { version = "0.1.3" } panic-halt = { version = "0.2" } rtt-target = { version = "0.5" } diff --git a/flashloader/image-loader.py b/flashloader/image-loader.py index 0529bbd..2731953 100755 --- a/flashloader/image-loader.py +++ b/flashloader/image-loader.py @@ -26,8 +26,8 @@ BAUD_RATE = 115200 BOOTLOADER_START_ADDR = 0x0 BOOTLOADER_END_ADDR = 0x3000 -BOOTLOADER_CRC_ADDR = BOOTLOADER_END_ADDR - 4 -BOOTLOADER_MAX_SIZE = BOOTLOADER_END_ADDR - BOOTLOADER_START_ADDR - 4 +BOOTLOADER_CRC_ADDR = BOOTLOADER_END_ADDR - 2 +BOOTLOADER_MAX_SIZE = BOOTLOADER_END_ADDR - BOOTLOADER_START_ADDR - 2 APP_A_START_ADDR = 0x3000 APP_A_END_ADDR = 0x11800 @@ -209,7 +209,7 @@ class ImageLoader: # Blank the checksum. For the bootloader, the bootloader will calculate the # checksum itself on the initial run. checksum_write_packet = pack_memory_write_command( - BOOTLOADER_CRC_ADDR, bytes([0x00, 0x00, 0x00, 0x00]) + BOOTLOADER_CRC_ADDR, bytes([0x00, 0x00]) ) self.send_tc(checksum_write_packet) else: diff --git a/flashloader/slot-a-blinky/memory.x b/flashloader/slot-a-blinky/memory.x index 95e53ca..e462ed6 100644 --- a/flashloader/slot-a-blinky/memory.x +++ b/flashloader/slot-a-blinky/memory.x @@ -1,7 +1,7 @@ /* Special linker script for application slot A with an offset at address 0x3000 */ MEMORY { - FLASH : ORIGIN = 0x00000000, LENGTH = 0x3000 /* 128K */ + FLASH : ORIGIN = 0x00003000, LENGTH = 0x20000 /* 128K */ RAM : ORIGIN = 0x10000000, LENGTH = 0x08000 /* 32K */ } diff --git a/flashloader/slot-b-blinky/memory.x b/flashloader/slot-b-blinky/memory.x index e65a785..6217336 100644 --- a/flashloader/slot-b-blinky/memory.x +++ b/flashloader/slot-b-blinky/memory.x @@ -1,7 +1,7 @@ /* Special linker script for application slot B with an offset at address 0x11800 */ MEMORY { - FLASH : ORIGIN = 0x00000000, LENGTH = 0x11800 /* 128K */ + FLASH : ORIGIN = 0x00011800, LENGTH = 0x20000 /* 128K */ RAM : ORIGIN = 0x10000000, LENGTH = 0x08000 /* 32K */ } diff --git a/flashloader/src/main.rs b/flashloader/src/main.rs index 1042bfe..59e5fa6 100644 --- a/flashloader/src/main.rs +++ b/flashloader/src/main.rs @@ -110,7 +110,7 @@ mod app { tm_prod: DataProducer, } - rtic_monotonics::systick_monotonic!(Mono, 10_000); + rtic_monotonics::systick_monotonic!(Mono, 1000); #[init] fn init(cx: init::Context) -> (Shared, Local) { @@ -134,7 +134,7 @@ mod app { UART_BAUDRATE.Hz(), ); let (tx, rx) = irq_uart.split(); - let mut rx = rx.into_rx_with_irq(&mut dp.sysconfig, &mut dp.irqsel, pac::interrupt::OC3); + let mut rx = rx.into_rx_with_irq(&mut dp.sysconfig, &mut dp.irqsel, pac::interrupt::OC0); let verif_reporter = VerificationReportCreator::new(0).unwrap(); diff --git a/vscode/launch.json b/vscode/launch.json index 77cffe3..d3ce0f8 100644 --- a/vscode/launch.json +++ b/vscode/launch.json @@ -451,5 +451,53 @@ ] } }, + { + "type": "cortex-debug", + "request": "launch", + "name": "Bootloader", + "servertype": "jlink", + "cwd": "${workspaceRoot}", + "device": "Cortex-M0", + "svdFile": "./va108xx/svd/va108xx.svd.patched", + "preLaunchTask": "bootloader", + "executable": "${workspaceFolder}/target/thumbv6m-none-eabi/debug/bootloader", + "interface": "jtag", + "runToEntryPoint": "main", + "rttConfig": { + "enabled": true, + "address": "auto", + "decoders": [ + { + "port": 0, + "timestamp": true, + "type": "console" + } + ] + } + }, + { + "type": "cortex-debug", + "request": "launch", + "name": "Flashloader", + "servertype": "jlink", + "cwd": "${workspaceRoot}", + "device": "Cortex-M0", + "svdFile": "./va108xx/svd/va108xx.svd.patched", + "preLaunchTask": "flashloader", + "executable": "${workspaceFolder}/target/thumbv6m-none-eabi/debug/flashloader", + "interface": "jtag", + "runToEntryPoint": "main", + "rttConfig": { + "enabled": true, + "address": "auto", + "decoders": [ + { + "port": 0, + "timestamp": true, + "type": "console" + } + ] + } + }, ] } diff --git a/vscode/tasks.json b/vscode/tasks.json index e5c297e..7f02120 100644 --- a/vscode/tasks.json +++ b/vscode/tasks.json @@ -1,270 +1,200 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "rust: cargo build", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build hal tests", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--bin", - "board-tests", - "--features", - "rt" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build rtt", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "rtt-log", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build systick", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "timer-ticks", - "--features", - "rt" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build uart", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "uart", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build spi", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "spi", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build pwm", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "pwm", - "--features", - "rt" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build cascade", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "cascade", - "--features", - "rt" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "uart-echo-rtic-example", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--bin", - "uart-echo-rtic", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "blinky-hal", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "blinky", - ], - "group": { - "kind": "build", - } - }, - { - "label": "rust: cargo build led blinky", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "blinky-leds", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build button blinky", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "blinky-button-irq", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build temp sensor", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "adt75-temp-sensor", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build button blinky rtic", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "blinky-button-rtic", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build accelerometer", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "adxl343-accelerometer" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rust: cargo build adc", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "max11619-adc", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "reb1-nvm", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--example", - "nvm", - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "rtic-example", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--bin", - "rtic-example", - ], - }, - { - "label": "embassy-example", - "type": "shell", - "command": "~/.cargo/bin/cargo", // note: full path to the cargo - "args": [ - "build", - "--bin", - "embassy-example", - ], - }, - ] + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "rust: cargo build", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build hal tests", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "board-tests", "--features", "rt"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build rtt", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "rtt-log"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build systick", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "timer-ticks", "--features", "rt"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build uart", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "uart"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build spi", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "spi"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build pwm", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "pwm", "--features", "rt"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build cascade", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "cascade", "--features", "rt"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "uart-echo-rtic-example", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "uart-echo-rtic"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "blinky-hal", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "blinky"], + "group": { + "kind": "build" + } + }, + { + "label": "rust: cargo build led blinky", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "blinky-leds"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build button blinky", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "blinky-button-irq"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build temp sensor", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "adt75-temp-sensor"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build button blinky rtic", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "blinky-button-rtic"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build accelerometer", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "adxl343-accelerometer"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rust: cargo build adc", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "max11619-adc"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "reb1-nvm", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--example", "nvm"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "rtic-example", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "rtic-example"] + }, + { + "label": "embassy-example", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "embassy-example"] + }, + { + "label": "bootloader", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "bootloader"] + }, + { + "label": "flashloader", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": ["build", "--bin", "flashloader"] + } + ] }