Skip to content

Commit

Permalink
NAND flash mode (#67)
Browse files Browse the repository at this point in the history
* Initial flash support
  • Loading branch information
Baldanos authored and bvernoux committed Dec 18, 2016
1 parent 85ec373 commit 5247a83
Show file tree
Hide file tree
Showing 9 changed files with 504 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static struct cmd_map {
{ T_ONEWIRE, cmd_mode_init },
{ T_TWOWIRE, cmd_mode_init },
{ T_THREEWIRE, cmd_mode_init },
{ T_FLASH, cmd_mode_init },
{ 0, NULL }
};

Expand Down
29 changes: 29 additions & 0 deletions hydrabus/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ t_token_dict tl_dict[] = {
{ T_SCRIPT, "script" },
{ T_FILE, "filename" },
{ T_ONEWIRE, "1-wire" },
{ T_FLASH, "flash" },

{ T_LEFT_SQ, "[" },
{ T_RIGHT_SQ, "]" },
Expand Down Expand Up @@ -1185,6 +1186,29 @@ t_token tokens_threewire[] = {
{ }
};

t_token tokens_mode_flash[] = {
{
T_SHOW,
.subtokens = tokens_mode_show,
.help = "Show flash parameters"
},
/* flash-specific commands */
{
T_ID,
.help = "Displays the ID and status registers"
},
/* BP commands */
{
T_EXIT,
.help = "Exit flash mode"
},
{ }
};

t_token tokens_flash[] = {
{ }
};

t_token tokens_gpio_mode[] = {
{
T_IN,
Expand Down Expand Up @@ -1581,6 +1605,11 @@ t_token tl_tokens[] = {
T_RNG,
.help = "Random number"
},
{
T_FLASH,
.subtokens = tokens_flash,
.help = "NAND flash mode"
},
{
T_DEBUG,
.subtokens = tokens_debug,
Expand Down
1 change: 1 addition & 0 deletions hydrabus/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ enum {
T_SCRIPT,
T_FILE,
T_ONEWIRE,
T_FLASH,

/* BP-compatible commands */
T_LEFT_SQ,
Expand Down
4 changes: 3 additions & 1 deletion hydrabus/hydrabus.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ HYDRABUSSRC = hydrabus/hydrabus.c \
hydrabus/hydrabus_mode_twowire.c \
hydrabus/hydrabus_mode_threewire.c \
hydrabus/hydrabus_mode_can.c \
hydrabus/hydrabus_mode_flash.c \
hydrabus/hydrabus_bbio.c \
hydrabus/hydrabus_bbio_spi.c \
hydrabus/hydrabus_bbio_pin.c \
Expand All @@ -24,7 +25,8 @@ HYDRABUSSRC = hydrabus/hydrabus.c \
hydrabus/hydrabus_bbio_i2c.c \
hydrabus/hydrabus_bbio_rawwire.c \
hydrabus/hydrabus_freq.c \
hydrabus/hydrabus_bbio_onewire.c
hydrabus/hydrabus_bbio_onewire.c \
hydrabus/hydrabus_bbio_flash.c \

# Required include directories
HYDRABUSINC = ./hydrabus
4 changes: 4 additions & 0 deletions hydrabus/hydrabus_bbio.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "hydrabus_bbio_i2c.h"
#include "hydrabus_bbio_rawwire.h"
#include "hydrabus_bbio_onewire.h"
#include "hydrabus_bbio_flash.h"

int cmd_bbio(t_hydra_console *con)
{
Expand Down Expand Up @@ -67,6 +68,9 @@ int cmd_bbio(t_hydra_console *con)
case BBIO_PIN:
bbio_mode_pin(con);
break;
case BBIO_FLASH:
bbio_mode_flash(con);
break;
case BBIO_RESET_HW:
return TRUE;
default:
Expand Down
13 changes: 13 additions & 0 deletions hydrabus/hydrabus_bbio.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//Hydrabus specific
#define BBIO_CAN 0b00001000
#define BBIO_PIN 0b00001001
#define BBIO_FLASH 0b00001010

#define BBIO_RESET_HW 0b00001111
#define BBIO_PWM 0b00010010
Expand Down Expand Up @@ -138,4 +139,16 @@
#define BBIO_ONEWIRE_READ 0b00000100
#define BBIO_ONEWIRE_BULK_TRANSFER 0b00010000

/*
* Flash-specific commands
*/
#define BBIO_FLASH_EN_LOW 0b00000010
#define BBIO_FLASH_EN_HIGH 0b00000011
#define BBIO_FLASH_WRITE_READ 0b00000100
#define BBIO_FLASH_WRITE_BYTE 0b00000101
#define BBIO_FLASH_WRITE_CMD 0b00000110
#define BBIO_FLASH_READ_BYTE 0b00000111
#define BBIO_FLASH_WAIT_READY 0b00001000
#define BBIO_FLASH_WRITE_ADDR 0b00010000

int cmd_bbio(t_hydra_console *con);
3 changes: 3 additions & 0 deletions hydrabus/hydrabus_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern const mode_exec_t mode_onewire_exec;
extern const mode_exec_t mode_twowire_exec;
extern const mode_exec_t mode_threewire_exec;
extern const mode_exec_t mode_can_exec;
extern const mode_exec_t mode_flash_exec;
extern t_token tokens_mode_spi[];
extern t_token tokens_mode_i2c[];
extern t_token tokens_mode_uart[];
Expand All @@ -53,6 +54,7 @@ extern t_token tokens_mode_onewire[];
extern t_token tokens_mode_twowire[];
extern t_token tokens_mode_threewire[];
extern t_token tokens_mode_can[];
extern t_token tokens_mode_flash[];

static struct {
int token;
Expand All @@ -68,6 +70,7 @@ static struct {
{ T_TWOWIRE, tokens_mode_twowire, &mode_twowire_exec },
{ T_THREEWIRE, tokens_mode_threewire, &mode_threewire_exec },
{ T_CAN, tokens_mode_can, &mode_can_exec },
{ T_FLASH, tokens_mode_flash, &mode_flash_exec },
};

const char hydrabus_mode_str_cs_enabled[] = "/CS ENABLED\r\n";
Expand Down
Loading

0 comments on commit 5247a83

Please sign in to comment.