Skip to content

Commit 072a628

Browse files
authored
Version 1.4.0 (#12)
* Initial commit TinyUSB interface * Improving speed of read and write routines * Adding switch for P2K edition * Initial commit Settings object * Adding settings widget * Refactoring hexviewer * Removing events * Templated installer * Tackling issue #10 * Fixing templated deployment * Adding OSHW image * Set colors via settings menu * Implementing color themes * Storing last file paths * Adding more color schemes * Setting custom font * Setting MD5sum as uppercase * Adding another color scheme * Tuning firmware and GUI * Fixing bug in read sector * Fixing bug in dialog selection * Upgrading actions to Qt 6.7.0 * Upgrading to Qt6 in CMakeLists.txt * Adding qtserialport module * Expanding libraries * Adding missing file * Adding serialport module * Adding OpenSSLv3 * Adding more ROMS and fixing function in SettingsWidget class * Tuning font size
1 parent ae626de commit 072a628

37 files changed

+1281
-1227
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ jobs:
4646
- name: Install Qt
4747
uses: jurplel/install-qt-action@v3
4848
with:
49-
version: '5.15.2'
49+
version: '6.7.0'
5050
target: 'desktop'
5151
arch: 'win64_msvc2019_64'
52+
tools: 'tools_opensslv3_x64'
53+
modules: 'qtserialport'
5254
cache: true
5355
- name: Configure CMake
5456
run: cmake -B ${{github.workspace}}/build -S ${{github.workspace}}/gui -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
@@ -59,26 +61,53 @@ jobs:
5961
with:
6062
name: ${{env.EXEC}}
6163
path: ${{github.workspace}}/build/Release/${{env.EXEC}}
62-
64+
65+
# create packaging metadata
66+
prepare-installer-windows:
67+
runs-on: ubuntu-latest
68+
needs: build-gui-windows
69+
permissions: write-all
70+
steps:
71+
- uses: actions/checkout@v3
72+
- name: install dependencies
73+
run: sudo apt-get update && sudo apt-get install -y python3 python3-jinja2
74+
- name: run packaging script
75+
run: python3 gui/packaging/package.py
76+
- name: Upload packaging scripts
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: package-metadata
80+
path: |
81+
${{github.workspace}}/gui/packaging/config/config.xml
82+
${{github.workspace}}/gui/packaging/packages/com.vendor.product/meta/installscript.qs
83+
${{github.workspace}}/gui/packaging/packages/com.vendor.product/meta/package.xml
84+
85+
# create Windows installer
6386
create-installer-windows:
6487
runs-on: windows-latest
65-
needs: build-gui-windows
88+
needs: prepare-installer-windows
6689
permissions: write-all
6790
steps:
6891
- uses: actions/checkout@v3
6992
- name: Install Qt
7093
uses: jurplel/install-qt-action@v3
7194
with:
72-
version: '5.15.2'
95+
version: '6.7.0'
7396
target: 'desktop'
7497
arch: 'win64_msvc2019_64'
75-
tools: 'tools_ifw'
98+
modules: 'qtserialport'
99+
tools: 'tools_ifw tools_opensslv3_x64'
76100
cache: true
77101
- name: Download artifact
78102
uses: actions/download-artifact@v3
79103
with:
80104
name: ${{env.EXEC}}
81105
path: gui/packaging/packages/com.vendor.product/data/
106+
- name: Download installer metadata
107+
uses: actions/download-artifact@v3
108+
with:
109+
name: package-metadata
110+
path: ${{github.workspace}}/gui/packaging
82111
- name: Get dependencies
83112
run: windeployqt.exe gui\packaging\packages\com.vendor.product\data\${{env.EXEC}} --release --force
84113
- name: Copy assets
@@ -92,6 +121,7 @@ jobs:
92121
name: ${{env.PROGNAME}}-installer-win64.exe
93122
path: gui/packaging/${{env.PROGNAME}}-installer-win64.exe
94123

124+
# deploy Windows installer
95125
deploy-installer-windows:
96126
runs-on: ubuntu-latest
97127
needs: [create-installer-windows, create-release]

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
66
[![License: CC BY-SA 4.0](https://img.shields.io/badge/License-CC%20BY--SA%204.0-blue.svg)](https://creativecommons.org/licenses/by-sa/4.0/)
77

8+
9+
[![OSHW](img/certification-mark-NL000020-wide.svg)](https://certification.oshwa.org/nl000020.html)
10+
811
## Purpose
912

1013
This open hardware project aims users to produce a low-cost flasher for the
@@ -53,4 +56,4 @@ Download the latest version of the binaries via the links below.
5356
## License
5457

5558
* All software is shared under the [GPL v3 license](https://www.gnu.org/licenses/gpl-3.0).
56-
* All hardware (e.g. KiCAD files and .stl files) are shared under the [CC-BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/).
59+
* All hardware (e.g. KiCAD files and .stl files) are shared under the [CC-BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/).

firmware/cmds.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ uint16_t get_uint16(const char* instruction, uint8_t offset) {
4949
* Return command back over serial
5050
*/
5151
void echo_command(const char* inst, uint8_t size) {
52-
for(unsigned int i=0; i<size; i++) {
53-
putchar_raw(inst[i]);
54-
}
55-
stdio_flush();
52+
tud_cdc_write(inst, size);
53+
tud_cdc_write_flush();
5654
}
5755

5856
/*

firmware/cmds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <string.h>
2727
#include <pico/stdlib.h>
2828
#include <pico/stdio.h>
29+
#include <tusb.h>
2930

3031
uint8_t get_uint8(const char* instruction, uint8_t offset);
3132
uint16_t get_uint16(const char* instruction, uint8_t offset);

firmware/constants.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,17 @@ GPIO19 - LOAD for A16-A19
4141
#define LED_RD 26
4242
#define LED_WR 27
4343

44-
#define DELAY_READ 5
45-
#define DELAY_WRITE 5
46-
#define DELAY_ADDR 4
47-
#define BOARD_ID "PICOSST39-v1.3.0"
44+
#define DELAY_READ 3
45+
#define DELAY_READ_VERIFY 1
46+
#define DELAY_WRITE 1
47+
#define DELAY_ADDR 1
48+
#define BOARD_ID "PICOSST39-v1.4.0"
49+
50+
#define BLOCK_SIZE 0x100
51+
#define SECTOR_SIZE 0x1000
52+
#define BANK_SIZE 0x4000
53+
54+
#define NOP __asm volatile ("nop\n");
55+
#define NOP50 __asm volatile ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n");
4856

4957
#endif

firmware/main.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
#include <stdlib.h>
2424
#include <string.h>
2525
#include <pico/stdlib.h>
26+
#include <tusb.h>
2627

2728
#include "routines.h"
2829
#include "cmds.h"
2930

3031
// command storage
3132
char instruction[9]; // stores single 8-byte instruction
3233
uint8_t inptr = 0; // instruction pointer
34+
uint8_t buf[64]; // usb buffer
3335

3436
// forward declarations
3537
void parse_instructions();
@@ -38,8 +40,12 @@ void parse_instructions();
3840
* Initialization routine that sets default pin configuration
3941
**/
4042
void init() {
43+
// initialize standard I/O
4144
stdio_init_all();
4245

46+
// initialize TinyUSB stack
47+
tusb_init();
48+
4349
// initialize GPIO0-GPIO19 + 26,27
4450
gpio_init_mask(0x00CFFFFFF);
4551

@@ -68,18 +74,25 @@ int main() {
6874
init();
6975

7076
while(true) {
71-
char c = getchar_timeout_us(100);
72-
73-
// only capture alphanumerical data
74-
if((c >= 48 && c <= 57) || (c >= 65 && c <=90)) {
75-
instruction[inptr] = c;
76-
inptr++;
77-
}
77+
78+
if (tud_cdc_connected()) {
79+
if (tud_cdc_available()) {
80+
char c = tud_cdc_read_char();
7881

79-
if(inptr == 8) {
80-
parse_instructions();
81-
inptr = 0;
82+
// only capture alphanumerical data
83+
if((c >= 48 && c <= 57) || (c >= 65 && c <=90)) {
84+
instruction[inptr] = c;
85+
inptr++;
86+
}
87+
88+
if(inptr == 8) {
89+
parse_instructions();
90+
inptr = 0;
91+
}
92+
}
8293
}
94+
95+
tud_task();
8396
}
8497
}
8598

firmware/ops.c

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,19 @@ void set_address(uint32_t addr) {
3030
uint32_t addrh = (addr >> 8) & 0xFF;
3131
uint32_t addru = (addr >> 16) & 0xFF;
3232

33-
gpio_put_masked(0xFF00, addrl << 8);
34-
gpio_put(ALS, true);
35-
sleep_us(DELAY_ADDR);
36-
gpio_put(ALS, false);
37-
38-
gpio_put_masked(0xFF00, addrh << 8);
39-
gpio_put(AHS, true);
40-
sleep_us(DELAY_ADDR);
41-
gpio_put(AHS, false);
42-
43-
gpio_put_masked(0x0700, addru << 8);
44-
gpio_put(AUS, true);
45-
sleep_us(DELAY_ADDR);
46-
gpio_put(AUS, false);
33+
set_address_upper(addru);
34+
set_address_high(addrh);
35+
set_address_low(addrl);
4736

4837
gpio_put(ROE, false); // enable address output
4938
}
5039

5140
/**
52-
* Set upper bits in address register
53-
**/
54-
void set_address_high(uint32_t addr) {
55-
set_address(addr & 0xFFFFFF00);
56-
}
57-
58-
/**
59-
* Set lower 8 bits in address register
60-
**/
61-
void set_address_low(uint32_t addr) {
62-
uint32_t addrl = addr & 0xFF;
63-
64-
gpio_put_masked(0xFF00, addrl << 8);
65-
gpio_put(ALS, true);
66-
sleep_us(DELAY_ADDR);
67-
gpio_put(ALS, false);
68-
69-
gpio_put(ROE, false); // enable address output
70-
}
71-
72-
/**
73-
* Read single byte from address
74-
**/
41+
* @brief Read a single byte from address
42+
*
43+
* @param addr full 19-bit address
44+
* @return uint8_t value at address
45+
*/
7546
uint8_t read_byte(uint32_t addr) {
7647
// set pins 0-7 to input
7748
gpio_set_dir_in_masked(0x000000FF);
@@ -91,24 +62,52 @@ uint8_t read_byte(uint32_t addr) {
9162
}
9263

9364
/**
94-
* Write byte at address
95-
**/
65+
* @brief Write a byte at address
66+
*
67+
* @param addr full 19-bit address
68+
* @param val 8-bit value to write
69+
*/
9670
void write_byte(uint32_t addr, uint8_t val) {
9771
// set pins 0-7 to output
9872
gpio_set_dir_out_masked(0x000000FF);
9973

74+
// set address on pins
10075
set_address(addr);
10176

77+
gpio_put_masked(0xFF, val);
10278
gpio_put(CE, false);
10379
gpio_put(PGM, false);
10480

105-
// sleep_us(DELAY_TIME);
106-
gpio_put_masked(0xFF, val);
10781
sleep_us(DELAY_WRITE);
10882

10983
gpio_put(PGM, true);
11084
gpio_put(CE, true);
11185

11286
// set pins 0-7 to input
11387
gpio_set_dir_in_masked(0x000000FF);
88+
}
89+
90+
/**
91+
* @brief Write byte at address while ignoring any upper bytes
92+
*
93+
* @param addr 16-bit combination of lower and higher address bits
94+
* @param val 8-bit value to write
95+
*
96+
* Assumes that:
97+
* - Pins are already set for output
98+
* - Chip is already active (CE)
99+
**/
100+
void write_byte_ignore_upper_fast(uint16_t addr, uint8_t val) {
101+
// set address on pins
102+
uint32_t addrl = addr & 0xFF;
103+
uint32_t addrh = (addr >> 8) & 0xFF;
104+
105+
set_address_high(addrh);
106+
set_address_low(addrl);
107+
gpio_put_masked(0xFF, val);
108+
109+
// toggle write
110+
gpio_put(PGM, false);
111+
sleep_us(DELAY_WRITE);
112+
gpio_put(PGM, true);
114113
}

0 commit comments

Comments
 (0)