Useful Information

Useful things to remember.

GCC - Dump Defines / Paths (12/6/2015)

Print out a define at compile time with gcc. The transition from XSTR to STR must be a two step process.

#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "value of define: " XSTR(define)

Dump all the defines that gcc defines:

gcc -dM -E - < /dev/null

Dump Include Paths:

gcc -Wl,--verbose

Dump Library Paths:

gcc -Wp,--verbose

Cygwin/MSYS2 - Move /home directory (12/5/2015)

To move /home in cygwin or msys2 you can use the mount command to mount a new path as /home. The syntax is mount, then options, then the new path and finally /home.

mount -o binary,posix=0,user,auto "m:\msys2\home" /home

Also, tabs are important when used at the front of lines. Make sure your editor isn't substituting sspaces for tabs.

Makefile - Printing a Makefile Variable (12/5/2015)

Print out a variable in a Makefile.

$(info $$var in [${var}])

Also, tabs are important when used at the front of lines. Make sure your editor isn't substituting sspaces for tabs.

Arduino - CLI Compile(5/9/2015)

To compile and download an Arduino Sketch using the CLI and get output back to your screen use the command below. You must have Cygwin installed.

c:\cygwin64\bin\mintty.exe --log - -e "C:\Program Files (x86)\arduino-1.6.3\arduino.exe" --upload --board arduino:avr:pro --port COM5 --verbose-upload "C:\Arduino\Sketches\HelloWorld\HelloWorld.ino"

Notepad++ - Custom Icons (5/9/2015)

To add a custom button to Notepad++.

  1. Setup NppExec script.
  2. Goto NppExec Advanced Options and add to Macro menu.
  3. Add bmp to %APPDATA%\Roaming\Notepad++\plugins\config\. BMP must be 16x16.
  4. Update %APPDATA%\Roaming\Notepad++\plugins\config\CustomizeToolbar.btn.

Bash - Search and Replace (1/4/2015)

To do a recursive search in linux or cygwin for files and update a string in each file.

$ find . -name '*Makefile' -exec sed -i -e 's/COM2/COM3/g' {} \;

Configure Admin Key-Based Authentication on ssh Server for Windows 10 (6/20/2020)

Put keys in C:\ProgramData\ssh\administrators_authorized_keys

Run PowerShell script to get correct file permissions:

$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys $acl.SetAccessRuleProtection($true, $false) $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow") $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow") $acl.SetAccessRule($administratorsRule) $acl.SetAccessRule($systemRule) $acl | Set-Acl

No comments: