Giter Site home page Giter Site logo

trellixvulnteam / vscode-spinasm_n8pj Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yann-ygn/vscode-spinasm

0.0 0.0 0.0 89.33 MB

A suite of tools to work with the FV1 chip from VSCode.

License: MIT License

JavaScript 75.19% C++ 24.57% PowerShell 0.25%

vscode-spinasm_n8pj's Introduction


Logo

VSCode-SpinASM

A set of tools to work with the Spinsemi FV-1 chip from VSCode.
VSCode module · Programmer · Programmer's firmware · Assembly resources



Table of content


About

The project aims to provide a cross-platform replacement for the SpinAsm software in the form of a module for the Microsoft VSCode editor. The cross-compilation part is done by the alternate asfv1 assembler, the compiled programs are then sent to an in-circuit EEPROM by either an ATMEL AVR based programmer or a simple Arduino board.

To get started, all you need is to install the module and build a programmer.


Building a programmer

From a PCB

A quick note about the current version of the PCB : there are some tight tolerances around the ICSP header mounting holes used to fix the SOIC clamp. Check your manufacturer's capabilities as you need a 0.25mm tolerance from non-plated thru hole to track. I've used JLCPCB's services to build it with no issues.

Board build

You can find the current gerber files here, there are two versions available :

  • Panel

A 150x100mm panel with mounting holes meant to be built using a stencil and this support tool.

  • Single

A single board to hand solder.

It is a very simple circuit that is basically a slimmed-down arduino board composed of a FTDI USB to UART chip and an AVR microcontroller, you can find the BOM here.

FTDI chip setup

The board is powered by the target circuit so you need to set the correct CBUS bits for the VBUS_SENSE pin and the RX/TX LEDs if you choose to include them in your build.

Windows

On Windows systems this is done using the FT_PROG utility from FTDI. it's pretty straightforward to use: power the board, connect it to a computer via USB and set the correct bits.

Linux

On Linux systems there are several ways to program the FTDI chips's EEPROM, i'm using the ftdi_eeprom package that's available on Debian/Ubuntu based distributions. Once it's installed simply power the board, connect it and you can use the pre-built configuration file and image to setup your device using the following command :

sudo ftdi_eeprom --device i:0x0403:0x6015 --flash-eeprom ft230x.conf

Firmware upload

The PCB uses the SOICbite footprint as an ICSP header, the pinout on the board is as follows:

Which out of my SOIC clamp translates to :

Pin ICSP pin
1 RST
2 +3.3V
3 SCK
4 NC
5 MISO
6 NC
7 MOSI
8 GND


The code requires a change in the base Arduino I2C library as the default buffer size is limited to 30 bytes, simply change the following value in the twi.h file:

#define TWI_BUFFER_LENGTH 34

The project uses VSCode and the PlatformIO module as a development environment, the repository is setup to upload the firmware via a generic AVRISP mkII programmer and target an ATmega28PB running at 12Mhz from an external crystal :

[env:ATmega328P]
platform = atmelavr
board = ATmega328PB
framework = arduino
board_build.mcu = atmega328pb
board_build.f_cpu = 12000000L
board_hardware.oscillator = external
board_upload.speed = 57600

upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    stk500v2
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

The next step is to set the fuse bits :

platformio run --target fuses

And finally upload the firmware :

platformio run --target upload

From an Arduino board

As there are many flavors of Arduino boards i will use two examples : the extremely common Arduino Uno that we probably all have laying around and what i suppose would the ideal board for that purpose, the Arduino Pro Mini running at 3.3V.

Board setup

Arduino Uno

The Arduino Uno is not the ideal candidate for that very specific purpose as in most incarnation it will run off a 5V power supply while the target EEPROM will run at 3.3V. But it has to be the most common Arduino board out there so why not use it, all that is needed to make it talk to the EEPROM are simple level shifters. They are available as pre-made boards but are really simple circuits :

Then the following pins are used to program the target circuit :

Arduino Pro Mini

The Arduino Pro Mini is pretty much what's inside the custom programmer minus the FTDI chip but any USB to UART adapter will do as long as it can work at 3.3V. It is recommended to power the Arduino board from the target circuit using the following pinout:

Firmware upload

The code requires a change in the base Arduino I2C library as the default buffer size is limited to 30 bytes, simply change the following value in the twi.h file:

#define TWI_BUFFER_LENGTH 34

After that, simply setup the platformio.ini file as follows, for the Uno :

[env:uno]
platform = atmelavr
framework = arduino
board = uno

Pro Mini :

[env:pro8MHzatmega328]
platform = atmelavr
framework = arduino
board = pro8MHzatmega328

And upload the firmware :

platformio.exe run --target upload

Programmer wiring

The target circuit should look like this and expose the following pins via some kind of header:


Using the VSCode module

Installation

As of right now the module is only available as a standalone installer, you will find it at the root of the source code folder.

Prerequisites

The module depends on the asfv1 compiler, it is avaialble on the Python Package Index. You can find the installation instrutions on the project's GitHub.

Usage

Projects

The module follows the same logic as the SpinAsm IDE and is centered around a project of 8 banks and programs:

The first thing you should do is to create a blank project by opening an empty folder and using the Create project structure command:

A blank project structure will look like this:

project/
├── bank_0/
│   ├── 0_programName.spn
├── bank_1/
│   ├── 1_programName.spn
├── bank_2/
│   ├── 2_programName.spn
├── bank_3/
│   ├── 3_programName.spn
├── bank_4/
│   ├── 4_programName.spn
├── bank_5/
│   ├── 5_programName.spn
├── bank_6/
│   ├── 6_programName.spn
├── bank_7/
│   ├── 7_programName.spn
├── output/
├── settings.ini

The folder should not be renamed but the programName part of the file can be changed.

Settings

The settings.ini file holds a few parameters you need to adjust to tell the module where the compiler is located and the programmer's path and baud rate. The default file is as follow :

;Project config file

[asfv1]
;Path of the executable
path = C:\\path\\to\\asfv1.exe

;Compiler options separated by a space :
; -c 	clamp out of range values without error
; -s 	read literals 2,1 as float (SpinASM compatibility)
; -q 	suppress warnings
options = -s

[serial]
;Serial port for the programmer
port = COM6
baudrate = 57600

On a Linux system it would look like this :

;Project config file

[asfv1]
;Path of the executable
path = /path/to/bin/asfv1

;Compiler options separated by a space :
; -c 	clamp out of range values without error
; -s 	read literals 2,1 as float (SpinASM compatibility)
; -q 	suppress warnings
options = -s

[serial]
;Serial port for the programmer
port = /dev/ttyUSB0
baudrate = 57600

The settings.ini file is read every time a project is compiled or uploaded so you can change the parameters on the go.


Links

vscode-spinasm_n8pj's People

Contributors

yann-ygn avatar trellixvulnteam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.