Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidated Commit from AWatterott fork #62

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add files via upload
  • Loading branch information
Sandeepan Sengupta authored Jan 2, 2019
commit 07c6a4b5e9827875db6136ac2fe681dea8cead8e
18 changes: 18 additions & 0 deletions boards/codebridge_cdc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "CodeBridge CDC Bootloader"
#define VOLUME_LABEL "CDC Bootloader"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xb010 // CDC Bootloader

#define BOARD_ID "CodeBridge CDC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/codebridge_msc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "CodeBridge MSC Bootloader"
#define VOLUME_LABEL "MSC Bootloader"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xb101 // MSC Bootloader

#define BOARD_ID "CodeBridge MSC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/domino_cdc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Domino CDC Bootloader"
#define VOLUME_LABEL "CDC Bootloader"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xE0E0 // CDC Bootloader

#define BOARD_ID "Domino CDC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/domino_msc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Domino MSC Bootloader"
#define VOLUME_LABEL "MSC Bootloader"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xF0F0 // MSC Bootloader

#define BOARD_ID "Domino MSC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/gravitino_cdc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Gravitino CDC Firmware"
#define VOLUME_LABEL "CDC Firmware"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xEEEE // CDC Firmware

#define BOARD_ID "Gravitino CDC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/gravitino_msc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Gravitino MSC Firmware"
#define VOLUME_LABEL "MSC Firmware"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xEFEF // MSC Firmware

#define BOARD_ID "Gravitino MSC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/infineo_cdc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Infineo CDC Firmware"
#define VOLUME_LABEL "CDC Firmware"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0x9999 // CDC Firmware

#define BOARD_ID "Infineo CDC"

#define LED_PIN PIN_PA17


#endif
18 changes: 18 additions & 0 deletions boards/infineo_msc/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H

#define __SAMD21G18A__ 1

#define VENDOR_NAME "Sandeepan Sengupta"
#define PRODUCT_NAME "Infineo MSC Firmware"
#define VOLUME_LABEL "MSC Firmware"

#define USB_VID 0x1209 // pid.codes
#define USB_PID 0xABCD // MSC Firmware

#define BOARD_ID "Infineo MSC"

#define LED_PIN PIN_PA17


#endif
59 changes: 36 additions & 23 deletions inc/uf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <stdio.h>
#include <string.h>

#include <compiler.h>

#undef DISABLE
#undef ENABLE

Expand All @@ -31,7 +33,7 @@
#define INDEX_URL "https://www.pxt.io/"
#endif

#include "uf2_version.h"
#include "uf2_version.h

// needs to be more than ~4200 (to force FAT16)
#define NUM_FAT_BLOCKS 8000
Expand Down Expand Up @@ -69,6 +71,7 @@
#define USE_MSC_CHECKS 0 // check validity of MSC commands; 460 bytes
#define USE_CDC_TERMINAL 0 // enable ASCII mode on CDC loop (not used by BOSSA); 228 bytes
#define USE_DBG_MSC 0 // output debug info about MSC
#define USE_BINARY_FILES 0 // enable Arduino bin-files in MSC; 296 bytes

#if USE_CDC
#define CDC_VERSION "S"
Expand Down Expand Up @@ -118,9 +121,15 @@
#define MSC_HANDOVER_VERSION ""
#endif

#if USE_BINARY_FILES
#define BINARY_VERSION "B"
#else
#define BINARY_VERSION ""
#endif

#define UF2_VERSION \
UF2_VERSION_BASE " " CDC_VERSION LOGS_VERSION FAT_VERSION ASSERT_VERSION HID_VERSION \
WEB_VERSION RESET_VERSION MSC_HANDOVER_VERSION
WEB_VERSION RESET_VERSION MSC_HANDOVER_VERSION BINARY_VERSION

// End of config

Expand All @@ -133,10 +142,10 @@
#define COLOR_UART 0x040400
#define COLOR_LEAVE 0x000000
#else
#define COLOR_START 0x000040
#define COLOR_USB 0x004000
#define COLOR_UART 0x404000
#define COLOR_LEAVE 0x400040
#define COLOR_START 0x00000A
#define COLOR_USB 0x000A00
#define COLOR_UART 0x0A0A00
#define COLOR_LEAVE 0x0A000A
#endif

/*
Expand All @@ -146,7 +155,7 @@ From CPU config:
#define FLASH_NB_OF_PAGES 512
*/

// These two need to be defined as plain decimal numbers, as we're using # on them
// These two need to be defined as plain decimal numbers, as we're using# on them
#define FLASH_ROW_SIZE 256
#ifndef FLASH_NUM_ROWS
#define FLASH_NUM_ROWS 1024
Expand Down Expand Up @@ -194,7 +203,7 @@ void panic(int code);

extern volatile bool b_sam_ba_interface_usart;
void flash_write_row(uint32_t *dst, uint32_t *src);
void flash_erase_to_end(uint32_t *start_address);
void flash_erase_row(uint32_t *dst);
void flash_write_words(uint32_t *dst, uint32_t *src, uint32_t n_words);
void copy_words(uint32_t *dst, uint32_t *src, uint32_t n_words);

Expand Down Expand Up @@ -223,12 +232,13 @@ void padded_memcpy(char *dst, const char *src, int len);
// Unlike for ordinary applications, our link script doesn't place the stack at the bottom
// of the RAM, but instead after all allocated BSS.
// In other words, this word should survive reset.
#ifdef SAMD21
#ifdef SAMD21
#define DBL_TAP_PTR ((volatile uint32_t *)(HMCRAMC0_ADDR + HMCRAMC0_SIZE - 4))
#endif
#ifdef SAMD51
#define DBL_TAP_PTR ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4))
#endif
#ifdef SAMD51
#define DBL_TAP_PTR ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4))
#endif

#define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set
#define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef

Expand All @@ -249,18 +259,21 @@ void led_signal(void);
void led_init(void);
void RGBLED_set_color(uint32_t color);

// Not all targets have a LED
#if defined(LED_PIN)
#define LED_MSC_OFF() PINOP(LED_PIN, OUTCLR)
#define LED_MSC_ON() PINOP(LED_PIN, OUTSET)
#define LED_MSC_TGL() PINOP(LED_PIN, OUTTGL)
#else
#define LED_MSC_OFF()
#define LED_MSC_ON()
#define LED_MSC_TGL()
#endif
// Not all targets have a LED
#if defined(LED_PIN)
#define LED_MSC_OFF() PINOP(LED_PIN, OUTCLR)
#define LED_MSC_ON() PINOP(LED_PIN, OUTSET)
#define LED_MSC_TGL() PINOP(LED_PIN, OUTTGL)
#else
#define LED_MSC_OFF()
#define LED_MSC_ON()
#define LED_MSC_TGL()
#endif

extern uint32_t timerHigh, resetHorizon;
#if USE_BINARY_FILES
extern uint32_t binary_files_timer;
#endif
void timerTick(void);
void delay(uint32_t ms);
void hidHandoverLoop(int ep);
Expand All @@ -270,7 +283,7 @@ void handoverPrep(void);
#define CONCAT_0(a, b) CONCAT_1(a, b)
#define STATIC_ASSERT(e) enum { CONCAT_0(_static_assert_, __LINE__) = 1 / ((e) ? 1 : 0) }

#ifdef SAMD21
#ifdef SAMD21
STATIC_ASSERT(FLASH_ROW_SIZE == FLASH_PAGE_SIZE * 4);
STATIC_ASSERT(FLASH_ROW_SIZE == NVMCTRL_ROW_SIZE);
STATIC_ASSERT(FLASH_NUM_ROWS * 4 == FLASH_NB_OF_PAGES);
Expand Down
Loading