Skip to content

Commit 2b3bf0b

Browse files
authored
Update to rebased latest version of locm3
Use enum usbd_request_return_codes type in control request handlers Use standard externs for _stack and vector_table Use desig_get_flash_size() in place of reading DESIG_FLASH_SIZE directly Use "modern" clock setup for STM32L1 Use PREFIX with embedded hyphen to match updated locm3 convention
1 parent a89c83f commit 2b3bf0b

10 files changed

Lines changed: 32 additions & 50 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
name: Compile firmware
2121
command: make -f release.Makefile -k all
2222
environment:
23-
PREFIX: "~/toolchains/gcc-arm-embedded/bin/arm-none-eabi"
23+
PREFIX: "~/toolchains/gcc-arm-embedded/bin/arm-none-eabi-"
2424
- store_artifacts:
2525
path: build/

libopencm3

Submodule libopencm3 updated 1016 files

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ clean::
3838
include rules.mk
3939

4040
size: $(OBJS) $(BINARY).elf
41-
@$(PREFIX)-size $(OBJS) $(BINARY).elf
41+
@$(PREFIX)size $(OBJS) $(BINARY).elf
4242

4343
debug: $(BINARY).elf
4444
-$(GDB) --tui --eval "target remote | $(OOCD) -f $(OOCD_INTERFACE) -f $(OOCD_BOARD) -f debug.cfg" $(BINARY).elf

src/dapboot.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include "winusb.h"
2828
#include "config.h"
2929

30-
/* Used only in the high memory bootloader */
31-
extern volatile const vector_table_t vector_table;
32-
3330
static inline void __set_MSP(uint32_t topOfMainStack) {
3431
asm("msr msp, %0" : : "r" (topOfMainStack));
3532
}

src/dfu.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ static void dfu_on_download_complete(usbd_device* usbd_dev, struct usb_setup_dat
9393
dfu_set_state(STATE_DFU_MANIFEST_SYNC);
9494
}
9595

96-
extern unsigned _stack;
97-
9896
static void dfu_on_download_request(usbd_device* usbd_dev, struct usb_setup_data* req) {
9997
(void)usbd_dev;
10098
(void)req;
@@ -144,15 +142,16 @@ static void dfu_on_manifest_request(usbd_device* usbd_dev, struct usb_setup_data
144142
}
145143
}
146144

147-
static int dfu_control_class_request(usbd_device *usbd_dev,
148-
struct usb_setup_data *req,
149-
uint8_t **buf, uint16_t *len,
150-
usbd_control_complete_callback* complete) {
145+
static enum usbd_request_return_codes
146+
dfu_control_class_request(usbd_device *usbd_dev,
147+
struct usb_setup_data *req,
148+
uint8_t **buf, uint16_t *len,
149+
usbd_control_complete_callback* complete) {
151150
if (req->wIndex != INTF_DFU) {
152151
return USBD_REQ_NEXT_CALLBACK;
153152
}
154153

155-
int status = USBD_REQ_HANDLED;
154+
enum usbd_request_return_codes status = USBD_REQ_HANDLED;
156155
switch (req->bRequest) {
157156
case DFU_GETSTATE: {
158157
struct dfu_getstate_response* resp;

src/rules.mk

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ OOCD_BOARD ?= target/stm32f1x.cfg
8181
####################################################################
8282
# Executables
8383

84-
PREFIX ?= arm-none-eabi
85-
86-
CC := $(PREFIX)-gcc
87-
CXX := $(PREFIX)-g++
88-
LD := $(PREFIX)-gcc
89-
AR := $(PREFIX)-gcc-ar
90-
AS := $(PREFIX)-as
91-
OBJCOPY := $(PREFIX)-objcopy
92-
OBJDUMP := $(PREFIX)-objdump
93-
GDB := $(PREFIX)-gdb
84+
PREFIX ?= arm-none-eabi-
85+
86+
CC := $(PREFIX)gcc
87+
CXX := $(PREFIX)g++
88+
LD := $(PREFIX)gcc
89+
AR := $(PREFIX)gcc-ar
90+
AS := $(PREFIX)as
91+
OBJCOPY := $(PREFIX)objcopy
92+
OBJDUMP := $(PREFIX)objdump
93+
GDB := $(PREFIX)gdb
9494
STFLASH = $(shell which st-flash)
9595

9696
####################################################################

src/stm32f103/target_stm32f103.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static uint16_t* get_flash_end(void) {
199199
return (uint16_t*)(FLASH_BASE + FLASH_SIZE_OVERRIDE);
200200
#else
201201
/* Only allow access to the chip's self-reported flash size */
202-
return (uint16_t*)(FLASH_BASE + (size_t)DESIG_FLASH_SIZE*FLASH_PAGE_SIZE);
202+
return (uint16_t*)(FLASH_BASE + ((size_t)desig_get_flash_size())*1024);
203203
#endif
204204
}
205205

src/stm32l1/target_stm32l1.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static const uint32_t CMD_BOOT = 0x544F4F42UL;
3333
void target_clock_setup(void) {
3434

3535
//#define MODERN_LOCM3
36-
#ifdef MODERN_LOCM3
3736
/* Clock struct for "any" board with a 16Mhz crystal */
3837
const struct rcc_clock_scale myclock_16m_hse = {
3938
.pll_source = RCC_CFGR_PLLSRC_HSE_CLK,
@@ -48,21 +47,6 @@ void target_clock_setup(void) {
4847
.apb1_frequency = 32e6,
4948
.apb2_frequency = 32e6,
5049
};
51-
#else
52-
const struct rcc_clock_scale myclock_16m_hse = {
53-
.pll_source = RCC_CFGR_PLLSRC_HSE_CLK,
54-
.pll_mul = RCC_CFGR_PLLMUL_MUL6,
55-
.pll_div = RCC_CFGR_PLLDIV_DIV3,
56-
.hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
57-
.ppre1 = RCC_CFGR_PPRE1_HCLK_NODIV,
58-
.ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
59-
.voltage_scale = PWR_SCALE1,
60-
.flash_config = FLASH_ACR_LATENCY_1WS,
61-
.ahb_frequency = 32000000,
62-
.apb1_frequency = 32000000,
63-
.apb2_frequency = 32000000,
64-
};
65-
#endif
6650

6751
rcc_clock_setup_pll(&myclock_16m_hse);
6852
}

src/webusb.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ static const struct webusb_url_descriptor landing_url_descriptor = {
5050
.URL = LANDING_PAGE_URL
5151
};
5252

53-
static int webusb_control_vendor_request(usbd_device *usbd_dev,
54-
struct usb_setup_data *req,
55-
uint8_t **buf, uint16_t *len,
56-
usbd_control_complete_callback* complete) {
53+
static enum usbd_request_return_codes
54+
webusb_control_vendor_request(usbd_device *usbd_dev,
55+
struct usb_setup_data *req,
56+
uint8_t **buf, uint16_t *len,
57+
usbd_control_complete_callback* complete) {
5758
(void)complete;
5859
(void)usbd_dev;
5960

6061
if (req->bRequest != WEBUSB_VENDOR_CODE) {
6162
return USBD_REQ_NEXT_CALLBACK;
6263
}
6364

64-
int status = USBD_REQ_NOTSUPP;
65+
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;
6566
switch (req->wIndex) {
6667
case WEBUSB_REQ_GET_URL: {
6768
if (req->wValue != 1) {

src/winusb.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ static const struct winusb_compatible_id_descriptor winusb_wcid = {
3939
}
4040
};
4141

42-
static int winusb_control_vendor_request(usbd_device *usbd_dev,
43-
struct usb_setup_data *req,
44-
uint8_t **buf, uint16_t *len,
45-
usbd_control_complete_callback* complete) {
42+
static enum usbd_request_return_codes
43+
winusb_control_vendor_request(usbd_device *usbd_dev,
44+
struct usb_setup_data *req,
45+
uint8_t **buf, uint16_t *len,
46+
usbd_control_complete_callback* complete) {
4647
(void)complete;
4748
(void)usbd_dev;
4849

4950
if (req->bRequest != WINUSB_MS_VENDOR_CODE) {
5051
return USBD_REQ_NEXT_CALLBACK;
5152
}
5253

53-
int status = USBD_REQ_NOTSUPP;
54+
enum usbd_request_return_codes status = USBD_REQ_NOTSUPP;
5455
if (((req->bmRequestType & USB_REQ_TYPE_RECIPIENT) == USB_REQ_TYPE_DEVICE) &&
5556
(req->wIndex == WINUSB_REQ_GET_COMPATIBLE_ID_FEATURE_DESCRIPTOR)) {
5657
*buf = (uint8_t*)(&winusb_wcid);

0 commit comments

Comments
 (0)