From d12a50e9b094053cf7c8d6bf123ae69972c0b579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caroline=20Sandsbr=C3=A5ten?= Date: Fri, 26 Sep 2025 15:59:07 +0200 Subject: [PATCH] add setup file --- jupyter/lab/1_SCA_Lab/Setup.ipynb | 118 ++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 jupyter/lab/1_SCA_Lab/Setup.ipynb diff --git a/jupyter/lab/1_SCA_Lab/Setup.ipynb b/jupyter/lab/1_SCA_Lab/Setup.ipynb new file mode 100644 index 0000000..255b086 --- /dev/null +++ b/jupyter/lab/1_SCA_Lab/Setup.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# DO NOT RUN THIS FILE\n", + "(Only run this file from another jupyter notebook where you already have )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import chipwhisperer as cw\n", + "\n", + "try:\n", + " if not scope.connectStatus:\n", + " scope.con()\n", + "except NameError:\n", + " scope = cw.scope()\n", + "\n", + "try:\n", + " if SS_VER == \"SS_VER_2_1\":\n", + " target_type = cw.targets.SimpleSerial2\n", + " elif SS_VER == \"SS_VER_2_0\":\n", + " raise OSError(\"SS_VER_2_0 is deprecated. Use SS_VER_2_1\")\n", + " else:\n", + " target_type = cw.targets.SimpleSerial\n", + "except:\n", + " SS_VER=\"SS_VER_1_1\"\n", + " target_type = cw.targets.SimpleSerial\n", + "\n", + "try:\n", + " target = cw.target(scope, target_type)\n", + "except:\n", + " print(\"INFO: Caught exception on reconnecting to target - attempting to reconnect to scope first.\")\n", + " print(\"INFO: This is a work-around when USB has died without Python knowing. Ignore errors above this line.\")\n", + " scope = cw.scope()\n", + " target = cw.target(scope, target_type)\n", + "\n", + "\n", + "print(\"INFO: Found ChipWhisperer😍\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if \"STM\" in PLATFORM or PLATFORM == \"CWLITEARM\" or PLATFORM == \"CWNANO\":\n", + " prog = cw.programmers.STM32FProgrammer\n", + "elif PLATFORM == \"CW303\" or PLATFORM == \"CWLITEXMEGA\":\n", + " prog = cw.programmers.XMEGAProgrammer\n", + "elif \"neorv32\" in PLATFORM.lower():\n", + " prog = cw.programmers.NEORV32Programmer\n", + "elif PLATFORM == \"CW308_SAM4S\" or PLATFORM == \"CWHUSKY\":\n", + " prog = cw.programmers.SAM4SProgrammer\n", + "else:\n", + " prog = None" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import time\n", + "time.sleep(0.05)\n", + "scope.default_setup()\n", + "\n", + "def reset_target(scope):\n", + " if PLATFORM == \"CW303\" or PLATFORM == \"CWLITEXMEGA\":\n", + " scope.io.pdic = 'low'\n", + " time.sleep(0.1)\n", + " scope.io.pdic = 'high_z' #XMEGA doesn't like pdic driven high\n", + " time.sleep(0.1) #xmega needs more startup time\n", + " elif \"neorv32\" in PLATFORM.lower():\n", + " raise IOError(\"Default iCE40 neorv32 build does not have external reset - reprogram device to reset\")\n", + " elif PLATFORM == \"CW308_SAM4S\" or PLATFORM == \"CWHUSKY\":\n", + " scope.io.nrst = 'low'\n", + " time.sleep(0.25)\n", + " scope.io.nrst = 'high_z'\n", + " time.sleep(0.25)\n", + " else: \n", + " scope.io.nrst = 'low'\n", + " time.sleep(0.05)\n", + " scope.io.nrst = 'high_z'\n", + " time.sleep(0.05)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}