Skip to content

Commit

Permalink
fixing build for ARM64 (no bswap)
Browse files Browse the repository at this point in the history
  • Loading branch information
MX682X committed Nov 23, 2024
1 parent 3b36454 commit fbffbf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
29 changes: 19 additions & 10 deletions src/pickit5.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,16 @@ static int pickit5_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
const unsigned char *set_speed = my.scripts.SetSpeed;
unsigned int set_speed_len = my.scripts.SetSpeed_len;
unsigned char buf[4];
if (set_speed_len > 0) { // debugWire is fun . . .
pickit5_uint32_to_array(buf, frq);
if(pickit5_send_script(pgm, SCR_CMD, set_speed, set_speed_len, buf, 4, 0) >= 0) {
if(pickit5_read_response(pgm) >= 0)
return 0;
}
if (set_speed == NULL) { // debugWire is fun . . .
return 0; // No script, to execute, return success
}

pickit5_uint32_to_array(buf, frq);
if(pickit5_send_script(pgm, SCR_CMD, set_speed, set_speed_len, buf, 4, 0) >= 0) {
if(pickit5_read_response(pgm) >= 0)
return 0;
}

pmsg_error("Failed to set speed.\n");
return -1;
}
Expand Down Expand Up @@ -1346,8 +1349,11 @@ static int pickit5_isp_write_fuse(const PROGRAMMER *pgm, const AVRMEM *mem, unsi
avr_set_bits(mem->op[AVR_OP_WRITE], (unsigned char*)&cmd);
avr_set_addr(mem->op[AVR_OP_WRITE], (unsigned char*)&cmd, mem_fuse_offset(mem));
avr_set_input(mem->op[AVR_OP_WRITE], (unsigned char*)&cmd, value);
cmd = __builtin_bswap32(cmd); // Swap bitorder
pickit5_uint32_to_array(&write_fuse_isp[11], cmd); // fill programming command

write_fuse_isp[14] = (uint8_t) cmd; // swap bitorder and fill array
write_fuse_isp[13] = (uint8_t) (cmd >> 8);
write_fuse_isp[12] = (uint8_t) (cmd >> 16);
write_fuse_isp[11] = (uint8_t) (cmd >> 24);

if(pickit5_send_script_cmd(pgm, write_fuse_isp, write_fuse_isp_len, NULL, 0) < 0) {
pmsg_error("Write Fuse Script failed");
Expand All @@ -1373,8 +1379,11 @@ static int pickit5_isp_read_fuse(const PROGRAMMER *pgm, const AVRMEM *mem, unsig
unsigned int cmd;
avr_set_bits(mem->op[AVR_OP_READ], (unsigned char*)&cmd);
avr_set_addr(mem->op[AVR_OP_READ], (unsigned char*)&cmd, mem_fuse_offset(mem));
cmd = __builtin_bswap32(cmd); // Swap bitorder
pickit5_uint32_to_array(&read_fuse_isp[11], cmd); // fill programming command

read_fuse_isp[14] = (uint8_t) cmd; // swap bitorder and fill array
read_fuse_isp[13] = (uint8_t) (cmd >> 8);
read_fuse_isp[12] = (uint8_t) (cmd >> 16);
read_fuse_isp[11] = (uint8_t) (cmd >> 24);

if(pickit5_send_script_cmd(pgm, read_fuse_isp, read_fuse_isp_len, NULL, 0) < 0) {
pmsg_error("Read Fuse Script failed");
Expand Down
5 changes: 0 additions & 5 deletions src/pickit5_lut_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const unsigned char ExitProgMode_dw_0[31] = {
0x1e, 0x4e, 0x90, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x1e, 0x40, 0x0c, 0x1e, 0x51, 0x1e, 0x4c,
};

const unsigned char SetSpeed_dw_0[0] = {
};

const unsigned char EraseChip_dw_0[1] = {
0xaf,
};
Expand Down Expand Up @@ -4199,15 +4196,13 @@ static void pickit_dw_script_init(SCRIPT *scr) {

scr->EnterProgMode = EnterProgMode_dw_0;
scr->ExitProgMode = ExitProgMode_dw_0;
scr->SetSpeed = SetSpeed_dw_0;
scr->EraseChip = EraseChip_dw_0;
scr->WriteMem8 = WriteMem8_dw_0;
scr->switchtoISP = switchtoISP_dw_0;
scr->WriteMemIO = WriteMemIO_dw_0;

scr->EnterProgMode_len = sizeof(EnterProgMode_dw_0);
scr->ExitProgMode_len = sizeof(ExitProgMode_dw_0);
scr->SetSpeed_len = sizeof(SetSpeed_dw_0);
scr->EraseChip_len = sizeof(EraseChip_dw_0);
scr->WriteMem8_len = sizeof(WriteMem8_dw_0);
scr->switchtoISP_len = sizeof(switchtoISP_dw_0);
Expand Down
4 changes: 2 additions & 2 deletions tools/scripts_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ def convert_xml(xml_path, c_funcs):
func_bytes = bytes(scr_bytes_buffer[:counter]) # create an immutable bytes array
break

if func_bytes == None:
continue # continue with next chip if somethin went wrong
if func_bytes == None or len(func_bytes) == 0:
continue # continue with next chip if somethin went wrong or is empty (SetSpeed_dw)

if function_name not in function_dict[programming_mode].keys():
function_dict[programming_mode][function_name] = []
Expand Down

0 comments on commit fbffbf7

Please sign in to comment.