Skip to content

Instantly share code, notes, and snippets.

@muttiopenbts
muttiopenbts / ftpserver.py
Last active January 5, 2017 18:29 — forked from scturtle/ftpserver.py
simple ftp server by python
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
import sys
#import traceback
allow_delete = False
local_ip = sys.argv[1]
local_port = 21
'''
Test script for interacting with device over modbus-rtc.
Need to improve received strings to output correctly after decoding.
'''
import pymodbus
import serial
from pymodbus.constants import Endian
from pymodbus.pdu import ModbusRequest
from pymodbus.client.sync import ModbusSerialClient as ModbusClient #initialize a serial RTU client instance
'''
pip uninstall crypto
pip install pycrypto
Tested using python 3
'''
def sign_data(private_key_loc, data, pass_phrase=None):
'''
param: private_key_loc Path to your private key
param: data, plain text data to be signed
param: pass_phrase if private key is protected
@muttiopenbts
muttiopenbts / gen_ivt.py
Created August 19, 2019 02:25
Generate ivt binary for use when running an imx6 SoC in HAB mode. Helper towards signing kernel images.
def gen_ivt(loadaddr, image_file):
'''Generate imx SoC ivt
Args:
loadaddr int. Hex representing load address in ram for uboot.
Can be obtained from your u-boot.cfg build file.
image_file string. filename and path to binary image. If
generating ivt for signing kernel image, ensure kernel
image file is pre-padded.
returns:
@muttiopenbts
muttiopenbts / imx6_uboot_script.txt
Last active September 2, 2019 01:48
This is a stripped down version of Boundary device's 6x_bootscript for hab signed kernel
# This is a stripped down version of Boundary device's 6x_bootscript
# which I used for learning and testing my hab images for imx6
# Prepare uboot script command
#u-boot-imx6$ ./tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "my boot script" -d imx6_uboot_script.txt /tftpboot/imx6_uboot_script
setenv dtype mmc
setenv disk 0
setenv active_partition 1
# setenv kernel_img_name zImage
@muttiopenbts
muttiopenbts / 6x_bootscript.txt
Created September 2, 2019 01:38
Boundary device's 6x_bootscript which I used for learning and testing my hab images for imx6
setenv bootargs ''
# setenv kernel_img_name zImage
setenv kernel_img_name zImage_signed_10800000
setenv initrd_high 0xffffffff
m4=''
a_base=0x10000000
if itest.s x51 == "x${cpu}" ; then
a_base=0x90000000
@muttiopenbts
muttiopenbts / 6x_bootscript.txt
Created September 2, 2019 04:45
Original 6x_bootscript taken from sdcard
setenv bootargs ''
setenv initrd_high 0xffffffff
m4=''
a_base=0x10000000
if itest.s x51 == "x${cpu}" ; then
a_base=0x90000000
elif itest.s x53 == "x${cpu}"; then
a_base=0x70000000
elif itest.s x6SX == "x${cpu}" || itest.s x7D == "x${cpu}"; then