Merge commit '77231e8972fa22cb233354ba5aed694dff4a9e24' into sam-update
This commit is contained in:
commit
50b9a4ceb6
@ -29,6 +29,7 @@
|
||||
#include "target.h"
|
||||
#include "morse.h"
|
||||
#include "version.h"
|
||||
#include "serialno.h"
|
||||
|
||||
#ifdef PLATFORM_HAS_TRACESWO
|
||||
# include "traceswo.h"
|
||||
@ -385,7 +386,7 @@ static bool cmd_target_power(target *t, int argc, const char **argv)
|
||||
#ifdef PLATFORM_HAS_TRACESWO
|
||||
static bool cmd_traceswo(target *t, int argc, const char **argv)
|
||||
{
|
||||
extern char *serial_no;
|
||||
char serial_no[13];
|
||||
(void)t;
|
||||
#if TRACESWO_PROTOCOL == 2
|
||||
uint32_t baudrate = SWO_DEFAULT_BAUD;
|
||||
@ -431,6 +432,7 @@ static bool cmd_traceswo(target *t, int argc, const char **argv)
|
||||
#else
|
||||
traceswo_init(swo_channelmask);
|
||||
#endif
|
||||
serial_no_read(serial_no, sizeof(serial_no));
|
||||
gdb_outf("%s:%02X:%02X\n", serial_no, 5, 0x85);
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef __SERIALNO_H
|
||||
#define __SERIALNO_H
|
||||
|
||||
char *serialno_read(char *s);
|
||||
char *serial_no_read(char *s, int max);
|
||||
|
||||
#endif
|
||||
|
@ -395,9 +395,9 @@ static const struct usb_config_descriptor config = {
|
||||
};
|
||||
|
||||
#if defined(STM32L0) || defined(STM32F3) || defined(STM32F4)
|
||||
char serial_no[13];
|
||||
static char serial_no[13];
|
||||
#else
|
||||
char serial_no[9];
|
||||
static char serial_no[9];
|
||||
#endif
|
||||
|
||||
static const char *usb_strings[] = {
|
||||
@ -555,7 +555,7 @@ void cdcacm_init(void)
|
||||
{
|
||||
void exti15_10_isr(void);
|
||||
|
||||
serialno_read(serial_no);
|
||||
serial_no_read(serial_no, sizeof(serial_no));
|
||||
|
||||
usbdev = usbd_init(&USB_DRIVER, &dev, &config, usb_strings,
|
||||
sizeof(usb_strings)/sizeof(char *),
|
||||
|
@ -5,8 +5,10 @@ CFLAGS +=-I ./target -I./platforms/pc
|
||||
|
||||
ifneq (, $(findstring linux, $(SYS)))
|
||||
SRC += serial_unix.c
|
||||
ifeq ($(ASAN), 1)
|
||||
CFLAGS += -fsanitize=address
|
||||
LDFLAGS += -lasan
|
||||
endif
|
||||
else ifneq (, $(findstring mingw, $(SYS)))
|
||||
SRC += serial_win.c
|
||||
LDFLAGS += -lws2_32
|
||||
|
@ -1,11 +1,12 @@
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
SERIAL_NO ?= 1
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
|
||||
INCLUDES = -I../libopencm3/include
|
||||
|
||||
CPU_FLAGS = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CFLAGS += $(INCLUDES) $(CPU_FLAGS) -DTARGET_IS_BLIZZARD_RB1 -DLM4F -DPART_TM4C123GH6PM
|
||||
CFLAGS += $(INCLUDES) $(CPU_FLAGS) -DSERIAL_NO=$(SERIAL_NO) -DTARGET_IS_BLIZZARD_RB1 -DLM4F -DPART_TM4C123GH6PM
|
||||
|
||||
LINKER_SCRIPT="platforms/tm4c/tm4c.ld"
|
||||
LDFLAGS = -nostartfiles -lc $(CPU_FLAGS) -nodefaultlibs -T$(LINKER_SCRIPT) -Wl,--gc-sections \
|
||||
|
@ -118,20 +118,20 @@ const char *platform_target_voltage(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *serialno_read(char *s)
|
||||
char *serial_no_read(char *s, int max)
|
||||
{
|
||||
/* FIXME: Store a unique serial number somewhere and retreive here */
|
||||
uint32_t unique_id = 1;
|
||||
uint32_t unique_id = SERIAL_NO;
|
||||
int i;
|
||||
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
for(i = 0; i < max - 1; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
s[8] = 0;
|
||||
s[max] = 0;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ static void setup_vbus_irq(void);
|
||||
* 000 - Original production build.
|
||||
* 001 - Mini production build.
|
||||
* 010 - Mini V2.0e and later.
|
||||
* 011 - Mini V2.1e and later.
|
||||
*/
|
||||
int platform_hwversion(void)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ int usbuart_debug_write(const char *buf, size_t len);
|
||||
* LED1 = PB10 (Yellow LED : Idle)
|
||||
* LED2 = PB11 (Red LED : Error)
|
||||
*
|
||||
* TPWR = RB0 (input) -- analogue on mini design ADC1, ch8
|
||||
* TPWR = PB0 (input) -- analogue on mini design ADC1, ch8
|
||||
* nTRST = PB1 (output) [blackmagic]
|
||||
* PWR_BR = PB1 (output) [blackmagic_mini] -- supply power to the target, active low
|
||||
* TMS_DIR = PA1 (output) [blackmagic_mini v2.1] -- choose direction of the TCK pin, input low, output high
|
||||
|
@ -19,32 +19,27 @@
|
||||
*/
|
||||
#include "general.h"
|
||||
|
||||
char *serialno_read(char *s)
|
||||
char *serial_no_read(char *s, int max)
|
||||
{
|
||||
#if defined(STM32L0) || defined(STM32F3) || defined(STM32F4)
|
||||
volatile uint16_t *uid = (volatile uint16_t *)DESIG_UNIQUE_ID_BASE;
|
||||
#if defined(STM32F1)
|
||||
/* Only STM32F103 has no DFU Bootloader. Generate a ID comatible
|
||||
* with the BMP Bootloader since ages.
|
||||
*/
|
||||
uint32_t *unique_id_p = (uint32_t *)DESIG_UNIQUE_ID_BASE;
|
||||
uint32_t unique_id = *unique_id_p +
|
||||
*(unique_id_p + 1) +
|
||||
*(unique_id_p + 2);
|
||||
snprintf(s, max, "%08" PRIX32, unique_id);
|
||||
#else
|
||||
/* Use the same serial number as the ST DFU Bootloader.*/
|
||||
uint16_t *uid = (uint16_t *)DESIG_UNIQUE_ID_BASE;
|
||||
# if defined(STM32F4)
|
||||
int offset = 3;
|
||||
# elif defined(STM32L0) || defined(STM32F4)
|
||||
# elif defined(STM32L0) || defined(STM32F3)
|
||||
int offset = 5;
|
||||
#endif
|
||||
sprintf(s, "%04X%04X%04X",
|
||||
# endif
|
||||
snprintf(s, max, "%04X%04X%04X",
|
||||
uid[1] + uid[5], uid[0] + uid[4], uid[offset]);
|
||||
#else
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
|
||||
uint32_t unique_id = *unique_id_p +
|
||||
*(unique_id_p + 1) +
|
||||
*(unique_id_p + 2);
|
||||
int i;
|
||||
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
s[8] = 0;
|
||||
|
||||
#endif
|
||||
return s;
|
||||
|
@ -29,7 +29,7 @@ on STM8S-Disco on CN5/3
|
||||
Use first number!
|
||||
|
||||
[Blue Pill Schematics 2
|
||||
](https://wiki.stm32duino.com/images/a/ae/Bluepillpinout.gif) :
|
||||
](https://stm32duinoforum.com/forum/images/a/ae/wiki_subdomain/Bluepillpinout.gif) :
|
||||
Use second number!
|
||||
|
||||
Distinguish boards by checking the SWIM_IN connection PB9/PB10 seen on
|
||||
|
@ -146,6 +146,12 @@ uint32_t firmware_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
||||
do {
|
||||
swd_proc.swdptap_seq_out(request, 8);
|
||||
ack = swd_proc.swdptap_seq_in(3);
|
||||
if (ack == SWDP_ACK_FAULT) {
|
||||
/* On fault, abort() and repeat the command once.*/
|
||||
firmware_swdp_error(dp);
|
||||
swd_proc.swdptap_seq_out(request, 8);
|
||||
ack = swd_proc.swdptap_seq_in(3);
|
||||
}
|
||||
} while (ack == SWDP_ACK_WAIT && !platform_timeout_is_expired(&timeout));
|
||||
|
||||
if (ack == SWDP_ACK_WAIT)
|
||||
|
@ -108,6 +108,8 @@ const struct command_s sam3x_cmd_list[] = {
|
||||
#define CHIPID_CIDR_ARCH_SAM4SxA (0x88 << 20)
|
||||
#define CHIPID_CIDR_ARCH_SAM4SxB (0x89 << 20)
|
||||
#define CHIPID_CIDR_ARCH_SAM4SxC (0x8A << 20)
|
||||
#define CHIPID_CIDR_ARCH_SAM4SDB (0x99 << 20)
|
||||
#define CHIPID_CIDR_ARCH_SAM4SDC (0x9A << 20)
|
||||
#define CHIPID_CIDR_NVPTYP_MASK (0x07 << 28)
|
||||
#define CHIPID_CIDR_NVPTYP_FLASH (0x02 << 28)
|
||||
#define CHIPID_CIDR_NVPTYP_ROM_FLASH (0x03 << 28)
|
||||
@ -242,6 +244,8 @@ bool sam3x_probe(target *t)
|
||||
case CHIPID_CIDR_ARCH_SAM4SxA | CHIPID_CIDR_EPROC_CM4:
|
||||
case CHIPID_CIDR_ARCH_SAM4SxB | CHIPID_CIDR_EPROC_CM4:
|
||||
case CHIPID_CIDR_ARCH_SAM4SxC | CHIPID_CIDR_EPROC_CM4:
|
||||
case CHIPID_CIDR_ARCH_SAM4SDB | CHIPID_CIDR_EPROC_CM4:
|
||||
case CHIPID_CIDR_ARCH_SAM4SDC | CHIPID_CIDR_EPROC_CM4:
|
||||
t->driver = "Atmel SAM4S";
|
||||
target_add_ram(t, 0x20000000, 0x400000);
|
||||
size_t size = sam_flash_size(t->idcode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user