Skip to content
Snippets Groups Projects
Unverified Commit e89af87b authored by CNLohr's avatar CNLohr Committed by GitHub
Browse files

Merge pull request #63 from cnlohr/readme-and-minichlink

GDB with the ESP32-S2
parents efedecb3 d557e0f7
No related branches found
No related tags found
Loading
No preview for this file type
......@@ -7,7 +7,6 @@
#define APB_CLOCK SYSTEM_CORE_CLOCK
uint32_t count;
int main()
{
SystemInit48HSI();
......@@ -27,6 +26,8 @@ int main()
GPIOC->CFGLR &= ~(0xf<<(4*0));
GPIOC->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*0);
count = &count;
while(1)
{
GPIOD->BSHR = 1 | (1<<4); // Turn on GPIOs
......
......@@ -4,6 +4,12 @@ all : $(TOOLS)
CFLAGS:=-O0 -g3 -Wall
C_S:=minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c nhc-link042.c minichgdb.c
# General Note: To use with GDB, gdb-multiarch
# gdb-multilib {file}
# target remote :2345
ifeq ($(OS),Windows_NT)
LDFLAGS:=-lpthread -lusb-1.0 -lsetupapi
else
......@@ -20,13 +26,14 @@ else
endif
endif
# will need mingw-w64-x86-64-dev gcc-mingw-w64-x86-64
minichlink.exe : $(C_S)
x86_64-w64-mingw32-gcc -o $@ $^ -Os -s -lsetupapi ./libusb-1.0.dll
minichlink : minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c nhc-link042.c
minichlink : $(C_S)
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS)
minichlink.so : minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c nhc-link042.c
minichlink.so : $(C_S)
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS) -shared -fPIC
install_udev_rules :
......
This diff is collapsed.
This diff is collapsed.
......@@ -24,10 +24,10 @@ struct MiniChlinkFunctions
int (*HaltMode)( void * dev, int mode ); //0 for halt, 1 for reset, 2 for resume
int (*ConfigureNRSTAsGPIO)( void * dev, int one_if_yes_gpio );
// WARNING: Reading/writing must be at 32-bit boundaries for 32-bit sizes.
// WARNING: Writing binary blobs may write groups of 64-bytes.
// No boundary or limit rules. Must support any combination of alignment and size.
int (*WriteBinaryBlob)( void * dev, uint32_t address_to_write, uint32_t blob_size, uint8_t * blob );
int (*ReadBinaryBlob)( void * dev, uint32_t address_to_read_from, uint32_t read_size, uint8_t * blob );
int (*Erase)( void * dev, uint32_t address, uint32_t length, int type ); //type = 0 for fast, 1 for whole-chip
// MUST be 4-byte-aligned.
......@@ -35,6 +35,20 @@ struct MiniChlinkFunctions
int (*WriteWord)( void * dev, uint32_t address_to_write, uint32_t data );
int (*ReadWord)( void * dev, uint32_t address_to_read, uint32_t * data );
// Debugging operations.
// Note: You must already be in break mode to use these otherwise they
// will return nonsensical data.
// For x0...xN, use 0x1000 + regno.
// For PC, use 0x7b1
int (*ReadCPURegister)( void * dev, uint32_t regno, uint32_t * regret );
int (*WriteCPURegister)( void * dev, uint32_t regno, uint32_t regval );
// Actually returns 17 registers (All 16 CPU registers + the debug register)
int (*ReadAllCPURegisters)( void * dev, uint32_t * regret );
int (*WriteAllCPURegisters)( void * dev, uint32_t * regret );
int (*SetEnableBreakpoints)( void * dev, int halt_on_break, int single_step );
int (*WaitForFlash)( void * dev );
int (*WaitForDoneOp)( void * dev );
......@@ -57,9 +71,12 @@ struct MiniChlinkFunctions
int (*VendorCommand)( void * dev, const char * command );
// Do Not override these. they are cursed.
int (*WriteHalfWord)( void * dev, uint32_t address_to_write, uint32_t data );
int (*ReadHalfWord)( void * dev, uint32_t address_to_read, uint32_t * data );
// Probably no need to override these. The base layer handles them.
int (*WriteHalfWord)( void * dev, uint32_t address_to_write, uint16_t data );
int (*ReadHalfWord)( void * dev, uint32_t address_to_read, uint16_t * data );
int (*WriteByte)( void * dev, uint32_t address_to_write, uint8_t data );
int (*ReadByte)( void * dev, uint32_t address_to_read, uint8_t * data );
};
/** If you are writing a driver, the minimal number of functions you can implement are:
......@@ -86,6 +103,7 @@ struct InternalState
uint32_t flash_unlocked;
int lastwriteflags;
int processor_in_mode;
int autoincrement;
};
......@@ -123,5 +141,14 @@ int SetupAutomaticHighLevelFunctions( void * dev );
// Useful for converting numbers like 0x, etc.
int64_t SimpleReadNumberInt( const char * number, int64_t defaultNumber );
// For drivers to call
int DefaultVoidHighLevelState( void * dev );
// GDBSever Functions
int SetupGDBServer( void * dev );
int PollGDBServer( void * dev );
int IsGDBServerInShadowHaltState( void * dev );
void ExitGDBServer( void * dev );
#endif
......@@ -252,6 +252,7 @@ int ESPVoidHighLevelState( void * dev )
struct ESP32ProgrammerStruct * eps = (struct ESP32ProgrammerStruct *)dev;
Write2LE( eps, 0x05fe );
ESPFlushLLCommands( dev );
DefaultVoidHighLevelState( dev );
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment