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

RFC : completely remove flash-as-eeprom emulation for get/set_USER_ID #102

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ set(

include/can.h src/can.c
include/dfu.h src/dfu.c
include/flash.h src/flash.c
include/gpio.h src/gpio.c
include/led.h src/led.c
include/queue.h src/queue.c
Expand Down
35 changes: 0 additions & 35 deletions include/flash.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/gs_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ enum gs_usb_breq {
GS_USB_BREQ_DEVICE_CONFIG,
GS_USB_BREQ_TIMESTAMP,
GS_USB_BREQ_IDENTIFY,
GS_USB_BREQ_GET_USER_ID,
GS_USB_BREQ_SET_USER_ID,
GS_USB_BREQ_GET_USER_ID, //not implemented
GS_USB_BREQ_SET_USER_ID, //not implemented
GS_USB_BREQ_DATA_BITTIMING,
GS_USB_BREQ_BT_CONST_EXT,
};
Expand Down
11 changes: 1 addition & 10 deletions ldscripts/STM32F042X6.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ __STACK_SIZE = 1024;
__HEAP_SIZE = 2560;

__FLASH_SIZE = 32K;
__NVM_SIZE = 1K;

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE - __NVM_SIZE
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 6K
DATA (xrw) : ORIGIN = 0x08000000 + __FLASH_SIZE - __NVM_SIZE, LENGTH = __NVM_SIZE
}

ENTRY(Reset_Handler)
Expand Down Expand Up @@ -73,13 +71,6 @@ SECTIONS

__etext = ALIGN (4);

.user_data :
{
. = ALIGN(4);
*(.user_data)
. = ALIGN(4);
} > DATA

.data : AT (__etext)
{
__data_start__ = .;
Expand Down
10 changes: 1 addition & 9 deletions ldscripts/STM32F072XB.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ __STACK_SIZE = 2K;
__HEAP_SIZE = 10K;

__FLASH_SIZE = 128K;
__NVM_SIZE = 1K;

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE - __NVM_SIZE
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
DATA (xrw) : ORIGIN = 0x08000000 + __FLASH_SIZE - __NVM_SIZE, LENGTH = __NVM_SIZE
}


Expand Down Expand Up @@ -74,12 +72,6 @@ SECTIONS

__etext = ALIGN (4);

.user_data :
{
. = ALIGN(4);
*(.user_data)
. = ALIGN(4);
} > DATA

.data : AT (__etext)
{
Expand Down
13 changes: 2 additions & 11 deletions ldscripts/STM32F407XE.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ __STACK_SIZE = 32K;
__HEAP_SIZE = 64K;

__FLASH_SIZE = 512K;
__NVM_SIZE = 128K;

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE - __NVM_SIZE
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
DATA (xrw) : ORIGIN = 0x08000000 + __FLASH_SIZE - __NVM_SIZE, LENGTH = __NVM_SIZE
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE
RAM (rw) : ORIGIN = 0x20000000, LENGTH = 128K
}


Expand Down Expand Up @@ -74,13 +72,6 @@ SECTIONS

__etext = ALIGN (4);

.user_data :
{
. = ALIGN(4);
*(.user_data)
. = ALIGN(4);
} > DATA

.data : AT (__etext)
{
__data_start__ = .;
Expand Down
98 changes: 0 additions & 98 deletions src/flash.c

This file was deleted.

3 changes: 0 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ THE SOFTWARE.
#include "led.h"
#include "dfu.h"
#include "timer.h"
#include "flash.h"
#include "util.h"

void HAL_MspInit(void);
Expand All @@ -63,8 +62,6 @@ int main(void)
HAL_Init();
SystemClock_Config();

flash_load();

gpio_init();

led_init(&hLED, LEDRX_GPIO_Port, LEDRX_Pin, LEDRX_Active_High, LEDTX_GPIO_Port, LEDTX_Pin, LEDTX_Active_High);
Expand Down
24 changes: 0 additions & 24 deletions src/usbd_gs_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ THE SOFTWARE.
#include "gs_usb.h"
#include "can.h"
#include "timer.h"
#include "flash.h"

typedef struct {
uint8_t ep0_buf[CAN_CMD_PACKET_SIZE];
Expand Down Expand Up @@ -383,13 +382,6 @@ static uint8_t USBD_GS_CAN_EP0_RxReady(USBD_HandleTypeDef *pdev) {
}
break;

case GS_USB_BREQ_SET_USER_ID:
memcpy(&param_u32, hcan->ep0_buf, sizeof(param_u32));
if (flash_set_user_id(req->wValue, param_u32)) {
flash_flush();
}
break;

case GS_USB_BREQ_MODE:
if (req->wValue < NUM_CAN_CHANNEL) {

Expand Down Expand Up @@ -468,18 +460,13 @@ static uint8_t USBD_GS_CAN_DFU_Request(USBD_HandleTypeDef *pdev, USBD_SetupReqTy
static uint8_t USBD_GS_CAN_Config_Request(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
{
USBD_GS_CAN_HandleTypeDef *hcan = (USBD_GS_CAN_HandleTypeDef*) pdev->pClassData;
uint32_t d32;

switch (req->bRequest) {

case GS_USB_BREQ_HOST_FORMAT:
case GS_USB_BREQ_MODE:
case GS_USB_BREQ_BITTIMING:
case GS_USB_BREQ_IDENTIFY:
case GS_USB_BREQ_SET_USER_ID:
hcan->last_setup_request = *req;
USBD_CtlPrepareRx(pdev, hcan->ep0_buf, req->wLength);
break;

case GS_USB_BREQ_DEVICE_CONFIG:
memcpy(hcan->ep0_buf, &USBD_GS_CAN_dconf, sizeof(USBD_GS_CAN_dconf));
Expand All @@ -496,17 +483,6 @@ static uint8_t USBD_GS_CAN_Config_Request(USBD_HandleTypeDef *pdev, USBD_SetupRe
USBD_CtlSendData(pdev, hcan->ep0_buf, sizeof(hcan->sof_timestamp_us));
break;

case GS_USB_BREQ_GET_USER_ID:
if (req->wValue < NUM_CAN_CHANNEL) {
d32 = flash_get_user_id(req->wValue);
memcpy(hcan->ep0_buf, &d32, sizeof(d32));
USBD_CtlSendData(pdev, hcan->ep0_buf, sizeof(d32));
} else {
USBD_CtlError(pdev, req);
}
break;


default:
USBD_CtlError(pdev, req);
}
Expand Down