-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TB: Finalizing firmware and using it on first HW device
some features were removed (overhead): - resetting flashboard, testboard - [p] ping(), [v] version() suits as well The 3 main uses cases are there: - restting BusVoodoo - booting BusVoodoo into DFU mode - using multiplexer to test pins-test functionality
- Loading branch information
1 parent
e601623
commit 42c2811
Showing
2 changed files
with
106 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
# Purpose | ||
The BusVoodoo Testboard gives the [BusVoodoo E2E tests](https://git.boddenberg.it/busvoodoo-ci/tree/master/bv_e2e_tests) a possibility to test the pintest routine of the BusVoodoo. In this test one needs to connect one pin of the BusVoodoo to several other pins sequentially on the BusVoodoo itself. In order to do so the following hardware is used: | ||
The BusVoodoo Testboard is capable of resetting and rebooting the BusVoodoo into DFU mode in an automated manner. | ||
|
||
Resetting ensures that each testjob runs on a freshly booted BusVoodoo. Booting into DFU mode ensures that a firmware can be flashed even when the built-in update functionality of the BusVoodoo is broken. | ||
|
||
Additionally, the testboard provides a possibility to test the 'pins-test' routine of the BusVoodoo. In this test one needs to connect one pin of the BusVoodoo to several other pins sequentially on the BusVoodoo itself. | ||
|
||
Following hardware is used: | ||
|
||
- 1 x Arduino Nano + USB cable | ||
- 1 x 16 channel analog multiplexer (HC4067) | ||
- 1 x 4 port USB hub (with power switches per port) | ||
- 3 x MOSFET | ||
- some wires,... | ||
- 1 x 16 channel analog multiplexer breakout module (HC4067) | ||
- 2 x P-MOSFET | ||
- some wires, soldering iron,... | ||
|
||
The MOSFETs are used to reset (power off/on) each port of the USB hub, which is the host of all BusVoodoo test environment devices (BusVoodoo, Flashboard, Testboard). The USB hub will be physically connected to the jenkins slave's host to only need one USB port. | ||
Additionally, the Testboard can boot the BusVoodoo into DFU mode to flash the firmware. This shall be helpful when a broken firmware corrupted the BusVoodoo's built-in update functionality. | ||
 | ||
|
||
# How does it work? | ||
The [BusVoodoo E2E tests script](https://github.com/boddenberg-it/busvoodoo-ci/tree/master/bv_e2e_tests) opens an additional serial port to the Testboard and use the following commands: | ||
The [BusVoodoo E2E tests script](https://github.com/boddenberg-it/busvoodoo-ci/tree/master/bv_e2e_tests) opens an additional serial port to the testboard and use the following commands: | ||
|
||
- **p** pings Testboard | ||
- **b** boots the BusVoodoo into DFU mode | ||
- **d** disables the multiplexer (power down) | ||
- **s1101** sets multiplexer: bits stand for S0, S1, S2, S3 pins on the mulitplexer board | ||
- **g** returns the current multiplexer configuration "ACK: 0101" | ||
- **r{b,f,t}** resets the **B**usVoodoo, **F**lashboard, **T**estboard | ||
- **a** reset all devices | ||
- **g** returns the current multiplexer !state and its configuration "ACK: 0-0101" | ||
- **d** disables the multiplexer | ||
- **r** resets the BusVoodoo | ||
|
||
*Note: **s1001** also enables the multiplexer in case it has been disabled (**d**) before.* | ||
|
||
# "Schematics" | ||
|
||
tbc... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
/* | ||
DATE: 23.09.2018 | ||
MAINTAINER: [email protected] | ||
USED BOARD: Arduino Nano | ||
MAINTAINER: [email protected] | ||
USED MULTIPLEXER: CD74HC4067 CMOS 16 Channel Analog | ||
Digital Multiplexer Breakout Module | ||
read ./README.md and/or help function below for further information. | ||
*/ | ||
const char version[ ] = "BusVoodoo testboard v0.1"; | ||
// PINS | ||
// multiplexer (MP) | ||
int MP_VCC = 2; // D2 | ||
|
||
const char version[ ] = "BusVoodoo testboard v0.3"; | ||
|
||
// multiplexer (MP) pins (directly connected) | ||
int MP_VCC = 2;// D2 | ||
int MP_EN = 3; // D3 | ||
int MP_S0 = 4; // D4 | ||
int MP_S1 = 5; // D5 | ||
int MP_S2 = 6; // D6 | ||
int MP_S3 = 7; // D7 | ||
// BusVoodoo (BV) | ||
int BV_DFU_MODE = 14; // A0 | ||
// USB hub resets | ||
|
||
// BusVoodoo (BV) pins are not directly | ||
// connected. Pin A0 and A1 are connected | ||
// to the gate of a P-MOSFET. | ||
int BV_DFU_MODE = 14; // A0 | ||
int RESET_BUSVOODOO = 15; // A1 | ||
int RESET_FLASHBOARD = 16; // A2 | ||
int RESET_YOURSELF = 17; // A3 | ||
// A0 MOSFET connects BV DFU Pin to 5V | ||
// A1 MOSFET connects BV RST Pin to GND | ||
|
||
// buffer for incoming requests | ||
char b[16]; | ||
|
||
void setup() { | ||
// must be at first otheriwse a boot loop | ||
// will happen. (Initialised LOW) | ||
digitalWrite(RESET_YOURSELF, HIGH); | ||
|
||
// settings I/O modes | ||
pinMode(MP_S0, OUTPUT); | ||
pinMode(MP_S1, OUTPUT); | ||
|
@@ -37,48 +42,38 @@ void setup() { | |
pinMode(MP_VCC, OUTPUT); | ||
pinMode(BV_DFU_MODE, OUTPUT); | ||
pinMode(RESET_BUSVOODOO, OUTPUT); | ||
pinMode(RESET_FLASHBOARD, OUTPUT); | ||
pinMode(RESET_YOURSELF, OUTPUT); | ||
|
||
// pulling every output low | ||
digitalWrite(MP_S0, LOW); | ||
digitalWrite(MP_S1, LOW); | ||
digitalWrite(MP_S2, LOW); | ||
digitalWrite(MP_S3, LOW); | ||
// multiplexer is disabled when MP_EN is HIGH | ||
digitalWrite(MP_EN, HIGH); | ||
digitalWrite(MP_VCC, LOW); | ||
digitalWrite(MP_VCC, HIGH); | ||
digitalWrite(BV_DFU_MODE, LOW); | ||
digitalWrite(RESET_BUSVOODOO, LOW); | ||
digitalWrite(RESET_FLASHBOARD, LOW); | ||
digitalWrite(RESET_YOURSELF, HIGH); | ||
|
||
Serial.begin(9600); | ||
Serial.println("BusVoodoo testboard initialised..."); | ||
} | ||
|
||
void loop() { | ||
|
||
// check for pending request | ||
if (Serial.available() > 0) { | ||
|
||
fill_buffer(); | ||
|
||
char request = b[0]; | ||
|
||
switch (request) { | ||
case 'a': { | ||
reset_all(); | ||
} break; | ||
case 'b': { | ||
boot_bv_into_dfu_mode(); | ||
} break; | ||
case 'p': { | ||
ping(); | ||
} break; | ||
case 'g': { | ||
get_multiplexer(); | ||
} break; | ||
case 'r': { | ||
reset(b[1]); | ||
reset_busvoodoo(); | ||
} break; | ||
case 's': { | ||
set_multiplexer(b[1], b[2], b[3], b[4]); | ||
|
@@ -89,98 +84,108 @@ void loop() { | |
case 'v': { | ||
send_version(); | ||
} break; | ||
case 'h': { | ||
help(); | ||
} break; | ||
default: | ||
error("command not found"); | ||
} | ||
// flush buffer | ||
while (Serial.available() > 0) { | ||
Serial.read(); | ||
} | ||
} | ||
|
||
} | ||
|
||
// FUNCTIONS | ||
void help() { | ||
Serial.println(""); | ||
Serial.println(version); | ||
Serial.println("maintainer: [email protected]"); | ||
Serial.println("date: 22.09.2018"); | ||
Serial.println(""); | ||
Serial.println("This testboard provides following functionalities:"); | ||
Serial.println(" - [r] reset the BusVoodoo"); | ||
Serial.println(" - [b] boot BusVoodoo into DFU BOOT mode"); | ||
Serial.println(" - [g] get current multiplexer settings:"); | ||
Serial.println(" 'ACK: 0-1010' first bool represents !state of multiplexer,"); | ||
Serial.println(" second bool[] represents states of s0,s1,s2,s3"); | ||
Serial.println(""); | ||
Serial.println(" - [s1010] enable multiplexer and set channel, e.g. 1010 = 5 (LSB first)"); | ||
Serial.println(" Note: simply go from 0-8 for the pinstest"); | ||
Serial.println(""); | ||
Serial.println(" - [d] disable multiplexer"); | ||
Serial.println(" - [h] show this help"); | ||
Serial.println(" - [v] get version of firmware"); | ||
Serial.println(""); | ||
Serial.println("More information about:"); | ||
Serial.println("BusVoodo: https://busvoodoo.cuvoodoo.info/"); | ||
Serial.println("BusVoodo-CI: https://git.boddenberg.it/busvoodoo-ci/"); | ||
Serial.println(""); | ||
} | ||
|
||
// HELPERS | ||
void error(String e) { | ||
Serial.println("ERROR: " + e); | ||
} | ||
|
||
void ack(String a) { | ||
Serial.println("ACK: " + a); | ||
} | ||
|
||
// functions | ||
void fill_buffer() { | ||
for (int i = 0; i < 16; i++) { | ||
b[i] = Serial.read(); | ||
delay(5); // necessary otherwise | ||
// only first char is read | ||
delay(5); // necessary otherwise only first char is read | ||
} | ||
} | ||
|
||
void reset_all() { | ||
digitalWrite(RESET_BUSVOODOO, HIGH); | ||
//WIP digitalWrite(RESET_FLASHBOARD, LOW); | ||
digitalWrite(RESET_YOURSELF, LOW); | ||
// no ack can be send | ||
} | ||
|
||
// helper for get_multiplexer() | ||
char getState(int pin) { | ||
if (digitalRead(pin)) { | ||
return '1'; | ||
} | ||
return '0'; | ||
} | ||
|
||
void get_multiplexer() { | ||
String result = ""; | ||
result = result + getState(MP_S0); | ||
result = result + getState(MP_S1); | ||
result = result + getState(MP_S2); | ||
result = result + getState(MP_S3); | ||
ack(result); | ||
// EXPOSED FUNCTIONS | ||
// help is first occurring functions though | ||
void send_version() { | ||
ack(version); | ||
} | ||
|
||
void ping() { | ||
ack("pong"); | ||
void reset_busvoodoo() { | ||
digitalWrite(RESET_BUSVOODOO, HIGH); | ||
delay(50); | ||
digitalWrite(RESET_BUSVOODOO, LOW); | ||
ack("reset_busvoodoo()"); | ||
} | ||
|
||
void reset(char device) { | ||
switch (device) { | ||
case 'b': { | ||
digitalWrite(RESET_BUSVOODOO, HIGH); | ||
delay(500); | ||
digitalWrite(RESET_BUSVOODOO, LOW); | ||
ack("reset BusVoodoo"); | ||
} break; | ||
case 'f': { | ||
digitalWrite(RESET_FLASHBOARD, HIGH); | ||
delay(500); | ||
digitalWrite(RESET_FLASHBOARD, LOW); | ||
ack("reset flashboard"); | ||
} break; | ||
case 't': { | ||
digitalWrite(RESET_YOURSELF, LOW); | ||
} break; | ||
default: | ||
error("reset device not known (b|f|t)"); | ||
} | ||
void boot_bv_into_dfu_mode() { | ||
digitalWrite(BV_DFU_MODE, HIGH); | ||
reset_busvoodoo(); | ||
delay(5000); // give BusVoodoo | ||
// some time to boot into DFU | ||
digitalWrite(BV_DFU_MODE, LOW); | ||
ack("boot_bv_into_dfu_mode()"); | ||
} | ||
|
||
void disable_multiplexer() { | ||
digitalWrite(MP_VCC, LOW); | ||
digitalWrite(MP_EN, HIGH); | ||
digitalWrite(MP_S0, LOW); | ||
digitalWrite(MP_S1, LOW); | ||
digitalWrite(MP_S2, LOW); | ||
digitalWrite(MP_S3, LOW); | ||
ack("disable_multiplexer()"); | ||
} | ||
|
||
void send_version() { | ||
ack(version); | ||
void get_multiplexer() { | ||
String result = ""; | ||
result = result + getState(MP_EN); | ||
result = result + "-"; | ||
result = result + getState(MP_S0); | ||
result = result + getState(MP_S1); | ||
result = result + getState(MP_S2); | ||
result = result + getState(MP_S3); | ||
ack(result); | ||
} | ||
|
||
/* takes number [0,15] and uses | ||
the first 4 bits to set | ||
the multiplexer. | ||
*/ | ||
void set_multiplexer(char c0, char c1, char c2, char c3) { | ||
|
||
// disable multiplexer | ||
digitalWrite(MP_EN, HIGH); | ||
delay(500); | ||
delay(50); | ||
|
||
// set multiplexer | ||
if (c0 == '1') { | ||
|
@@ -204,25 +209,7 @@ void set_multiplexer(char c0, char c1, char c2, char c3) { | |
digitalWrite(MP_S3, LOW); | ||
} | ||
|
||
// enabler multiplexer | ||
digitalWrite(MP_EN, LOW); | ||
digitalWrite(MP_VCC, HIGH); | ||
ack("set_multiplexer()"); | ||
} | ||
|
||
void error(String e) { | ||
Serial.println("ERROR: " + e); | ||
} | ||
|
||
void ack(String a) { | ||
Serial.println("ACK: " + a); | ||
} | ||
|
||
void boot_bv_into_dfu_mode() { | ||
digitalWrite(BV_DFU_MODE, HIGH); | ||
digitalWrite(RESET_BUSVOODOO, HIGH); | ||
delay(500); | ||
digitalWrite(RESET_BUSVOODOO, LOW); | ||
delay(1000); | ||
digitalWrite(BV_DFU_MODE, LOW); | ||
ack("boot_bv_into_dfu_mode()"); | ||
} |