Skip to content

Commit

Permalink
Merge pull request #72 from pzanna/Dev_72
Browse files Browse the repository at this point in the history
Dev 72
  • Loading branch information
pzanna authored Jan 6, 2017
2 parents ec6c1cc + c3e709e commit a42ffbe
Show file tree
Hide file tree
Showing 7 changed files with 1,076 additions and 840 deletions.
2 changes: 1 addition & 1 deletion ZodiacFX/src/config/config_zodiac.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define CONFIG_ZODIAC_H_


#define VERSION "0.71" // Firmware version number
#define VERSION "0.72" // Firmware version number

#define MAX_OFP_VERSION 0x04

Expand Down
4 changes: 2 additions & 2 deletions ZodiacFX/src/config/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
* (requires the LWIP_TCP option)
*/
#define MEMP_NUM_TCP_PCB 3
#define MEMP_NUM_TCP_PCB 12

/**
* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
Expand All @@ -126,7 +126,7 @@
* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
* (requires the LWIP_TCP option)
*/
#define MEMP_NUM_TCP_SEG 8
#define MEMP_NUM_TCP_SEG 16

/**
* MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
Expand Down
32 changes: 16 additions & 16 deletions ZodiacFX/src/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/*
* This file is part of the Zodiac FX firmware.
* Copyright (c) 2016 Northbound Networks.
* Copyright (c) 2016 Google Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,7 +42,7 @@ extern uint8_t shared_buffer[SHARED_BUFFER_LEN];
static uint32_t page_addr;
//static uint32_t ul_rc;

static uint32_t ul_test_page_addr;
static uint32_t flash_page_addr;
static uint32_t ul_rc;
static uint32_t ul_idx;
static uint32_t ul_page_buffer[IFLASH_PAGE_SIZE / sizeof(uint32_t)];
Expand All @@ -62,49 +62,49 @@ void get_serial(uint32_t *uid_buf)
* Firmware update function
*
*/
void firmware_update_init(void)
int firmware_update_init(void)
{
ul_test_page_addr = NEW_FW_BASE;
flash_page_addr = NEW_FW_BASE;

/* Initialize flash: 6 wait states for flash writing. */
ul_rc = flash_init(FLASH_ACCESS_MODE_128, 6);
if (ul_rc != FLASH_RC_OK) {
printf("-F- Initialization error %lu\n\r", (unsigned long)ul_rc);
//printf("-F- Initialization error %lu\n\r", (unsigned long)ul_rc);
return 0;
}

// Unlock 8k lock regions (these should be unlocked by default)
uint32_t unlock_address = ul_test_page_addr;
uint32_t unlock_address = flash_page_addr;
while(unlock_address < IFLASH_ADDR + IFLASH_SIZE - (IFLASH_LOCK_REGION_SIZE - 1))
{
printf("-I- Unlocking region start at: 0x%08x\r\n", unlock_address);
//printf("-I- Unlocking region start at: 0x%08x\r\n", unlock_address);
ul_rc = flash_unlock(unlock_address,
unlock_address + (4*IFLASH_PAGE_SIZE) - 1, 0, 0);
if (ul_rc != FLASH_RC_OK)
{
printf("-F- Unlock error %lu\n\r", (unsigned long)ul_rc);
//printf("-F- Unlock error %lu\n\r", (unsigned long)ul_rc);
return 0;
}

unlock_address += IFLASH_LOCK_REGION_SIZE;
}

// Erase 3 64k sectors
uint32_t erase_address = ul_test_page_addr;
// Erase 192k
uint32_t erase_address = flash_page_addr;
while(erase_address < IFLASH_ADDR + IFLASH_SIZE - (ERASE_SECTOR_SIZE - 1))
{
printf("-I- Erasing sector with address: 0x%08x\r\n", erase_address);
//printf("-I- Erasing sector with address: 0x%08x\r\n", erase_address);
ul_rc = flash_erase_sector(erase_address);
if (ul_rc != FLASH_RC_OK)
{
printf("-F- Flash programming error %lu\n\r", (unsigned long)ul_rc);
//printf("-F- Flash programming error %lu\n\r", (unsigned long)ul_rc);
return 0;
}

erase_address += ERASE_SECTOR_SIZE;
}

return;
return 1;
}

/*
Expand All @@ -113,9 +113,9 @@ void firmware_update_init(void)
*/
int flash_write_page(uint8_t *flash_page)
{
if(ul_test_page_addr <= IFLASH_ADDR + IFLASH_SIZE - IFLASH_PAGE_SIZE)
if(flash_page_addr <= IFLASH_ADDR + IFLASH_SIZE - IFLASH_PAGE_SIZE)
{
ul_rc = flash_write(ul_test_page_addr, flash_page,
ul_rc = flash_write(flash_page_addr, flash_page,
IFLASH_PAGE_SIZE, 0);
}
else
Expand All @@ -129,7 +129,7 @@ int flash_write_page(uint8_t *flash_page)
return 0;
}

ul_test_page_addr += IFLASH_PAGE_SIZE;
flash_page_addr += IFLASH_PAGE_SIZE;

return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions ZodiacFX/src/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/*
* This file is part of the Zodiac FX firmware.
* Copyright (c) 2016 Northbound Networks.
* Copyright (c) 2016 Google Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -35,7 +35,7 @@
void get_serial(uint32_t *uid_buf);
void cli_update(void);
int flash_write_page(uint8_t *flash_page);
void firmware_update_init(void);
int firmware_update_init(void);
__no_inline RAMFUNC void firmware_update(void);
int xmodem_xfer(void);
void xmodem_clear_padding(uint8_t *buff);
Expand All @@ -44,7 +44,7 @@ void xmodem_clear_padding(uint8_t *buff);
#define X_ACK 0x06
#define X_NAK 0x15

#define ERASE_SECTOR_SIZE 65536
#define ERASE_SECTOR_SIZE 8192
#define NEW_FW_BASE (IFLASH_ADDR + (5*IFLASH_NB_OF_PAGES/8)*IFLASH_PAGE_SIZE)
#define NEW_FW_MAX_SIZE 196608

Expand Down
Loading

0 comments on commit a42ffbe

Please sign in to comment.