Skip to content
Open
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
6 changes: 3 additions & 3 deletions firmware/programmer/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ USB_DIR=../usb_cdc/
OBJ_DIR=obj/
LIB_DIR=../libs/
INCLUDE_DIR=../
TOOLCHAIN=../../../compiler/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-
TOOLCHAIN=arm-none-eabi-
APP_1=$(OBJ_DIR)$(APP_NAME)_1
APP_2=$(OBJ_DIR)$(APP_NAME)_2

Expand Down Expand Up @@ -54,8 +54,8 @@ USB_SRCS=hw_config.c stm32_it.c usb_prop.c usb_desc.c usb_istr.c usb_pwr.c \
usb_endp.c usb.c

SRCS=main.c system_stm32f10x.c syscalls.c fsmc_nand.c led.c uart.c jtag.c \
clock.c cdc.c nand_programmer.c nand_bad_block.c flash.c spi_flash.c \
$(USB_SRCS)
clock.c cdc.c nand_programmer.c nand_bad_block.c flash.c spi_nor_flash.c \
spi_nand_flash.c $(USB_SRCS)

OBJS=$(addprefix $(OBJ_DIR),$(SRCS:.c=.o)) \
$(addprefix $(OBJ_DIR),$(STARTUP:.s=.o))
Expand Down
4 changes: 2 additions & 2 deletions firmware/programmer/Makefile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ USB_SRCS=hw_config.c stm32_it.c usb_prop.c usb_desc.c usb_istr.c usb_pwr.c \
usb_endp.c usb.c

SRCS=main.c system_stm32f10x.c syscalls.c fsmc_nand.c led.c uart.c jtag.c \
clock.c cdc.c nand_programmer.c nand_bad_block.c flash.c spi_flash.c \
$(USB_SRCS)
clock.c cdc.c nand_programmer.c nand_bad_block.c flash.c spi_nor_flash.c \
spi_nand_flash.c $(USB_SRCS)

OBJS=$(addprefix $(OBJ_DIR)/,$(SRCS:.c=.o)) \
$(addprefix $(OBJ_DIR)/,$(STARTUP:.s=.o))
Expand Down
3 changes: 2 additions & 1 deletion firmware/programmer/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
#ifndef _CHIP_H_
#define _CHIP_H_

typedef struct __attribute__((__packed__))
typedef struct
{
uint8_t maker_id;
uint8_t device_id;
uint8_t third_id;
uint8_t fourth_id;
uint8_t fifth_id;
uint8_t sixth_id;
} chip_id_t;

#endif /* _CHIP_H_ */
2 changes: 1 addition & 1 deletion firmware/programmer/fsmc_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ static void nand_read_id(chip_id_t *nand_id)

data = *((__IO uint32_t *)(Bank_NAND_ADDR | DATA_AREA) + 1);
nand_id->fifth_id = ADDR_1st_CYCLE(data);
nand_id->sixth_id = ADDR_2nd_CYCLE(data);
}

static void nand_write_page_async(uint8_t *buf, uint32_t page,
Expand Down Expand Up @@ -510,4 +511,3 @@ flash_hal_t hal_fsmc =
.is_bb_supported = nand_is_bb_supported,
.enable_hw_ecc = nand_enable_hw_ecc,
};

15 changes: 6 additions & 9 deletions firmware/programmer/nand_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
#include "log.h"
#include "version.h"
#include "flash.h"
#include "spi_flash.h"
#include "spi_nor_flash.h"
#include "spi_nand_flash.h"
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <inttypes.h>

#define NP_PACKET_BUF_SIZE 64
#define NP_MAX_PAGE_SIZE 0x21C0 /* 8KB + 448 spare */
#define NP_MAX_PAGE_SIZE 0x22E8 /* 8KB + 744 spare */
#define NP_WRITE_ACK_BYTES 1984
#define NP_NAND_TIMEOUT 0x1000000

Expand Down Expand Up @@ -157,8 +158,6 @@ typedef struct __attribute__((__packed__))
chip_id_t nand_id;
} np_resp_id_t;

/* BB, write ack and error responses are aligned to the same size to avoid
* receiver wait for additional data */
typedef struct __attribute__((__packed__))
{
np_resp_t header;
Expand All @@ -170,14 +169,12 @@ typedef struct __attribute__((__packed__))
{
np_resp_t header;
uint64_t bytes_ack;
uint8_t dummy[4];
} np_resp_write_ack_t;

typedef struct __attribute__((__packed__))
{
np_resp_t header;
uint8_t err_code;
uint8_t dummy[11];
} np_resp_err_t;

typedef struct __attribute__((__packed__))
Expand Down Expand Up @@ -257,7 +254,7 @@ typedef struct
static np_comm_cb_t *np_comm_cb;
static np_prog_t prog;

static flash_hal_t *hal[] = { &hal_fsmc, &hal_spi };
static flash_hal_t *hal[] = { &hal_fsmc, &hal_spi_nor, &hal_spi_nand };

uint8_t np_packet_send_buf[NP_PACKET_BUF_SIZE];

Expand Down Expand Up @@ -321,9 +318,9 @@ static int _np_cmd_nand_read_id(np_prog_t *prog)
if (np_comm_cb)
np_comm_cb->send((uint8_t *)&resp, resp_len);

DEBUG_PRINT("Chip ID: 0x%x 0x%x 0x%x 0x%x 0x%x\r\n",
DEBUG_PRINT("Chip ID: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\r\n",
resp.nand_id.maker_id, resp.nand_id.device_id, resp.nand_id.third_id,
resp.nand_id.fourth_id, resp.nand_id.fifth_id);
resp.nand_id.fourth_id, resp.nand_id.fifth_id, resp.nand_id.sixth_id);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/programmer/spi_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ static void spi_flash_read_id(chip_id_t *chip_id)
chip_id->device_id = spi_flash_read_byte();
chip_id->third_id = spi_flash_read_byte();
chip_id->fourth_id = spi_flash_read_byte();
chip_id->fifth_id = spi_flash_read_byte();
chip_id->sixth_id = spi_flash_read_byte();

spi_flash_deselect_chip();
}
Expand Down
Loading