2021-05-03 20:48:10 +00:00
|
|
|
{ lib, stdenv, makeDesktopItem, copyDesktopItems, icoutils, fdupes, imagemagick, jdk11, fetchzip }:
|
|
|
|
# TODO: JDK16 causes STM32CubeMX to crash right now, so we fixed the version to JDK11
|
|
|
|
# This may be fixed in a future version of STM32CubeMX. This issue has been reported to ST:
|
|
|
|
# https://community.st.com/s/question/0D53W00000jnOzPSAU/stm32cubemx-crashes-on-launch-with-openjdk16
|
|
|
|
# If you're updating this derivation, check the link above to see if it's been fixed upstream
|
|
|
|
# and try replacing all occurrences of jdk11 with jre and test whether it works.
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2021-05-03 20:48:10 +00:00
|
|
|
iconame = "STM32CubeMX";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "stm32cubemx";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "6.6.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
src = fetchzip {
|
2021-05-03 20:48:10 +00:00
|
|
|
url = "https://sw-center.st.com/packs/resource/library/stm32cube_mx_v${builtins.replaceStrings ["."] [""] version}-lin.zip";
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-NfJMXHQ7JXzRSdOAYfx2t0xsi/w2S5FK3NovcsDOi+E=";
|
2021-05-03 20:48:10 +00:00
|
|
|
stripRoot = false;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-03 20:48:10 +00:00
|
|
|
nativeBuildInputs = [ icoutils fdupes imagemagick copyDesktopItems];
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "stm32CubeMX";
|
|
|
|
exec = "stm32cubemx";
|
|
|
|
desktopName = "STM32CubeMX";
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Development" ];
|
2021-05-03 20:48:10 +00:00
|
|
|
comment = "STM32Cube initialization code generator";
|
|
|
|
icon = "stm32cubemx";
|
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
2021-05-03 20:48:10 +00:00
|
|
|
mkdir -p $out/{bin,opt/STM32CubeMX}
|
|
|
|
cp -r $src/MX/. $out/opt/STM32CubeMX/
|
|
|
|
chmod +rx $out/opt/STM32CubeMX/STM32CubeMX
|
2020-04-24 23:36:52 +00:00
|
|
|
cat << EOF > $out/bin/${pname}
|
|
|
|
#!${stdenv.shell}
|
2021-05-03 20:48:10 +00:00
|
|
|
${jdk11}/bin/java -jar $out/opt/STM32CubeMX/STM32CubeMX
|
2020-04-24 23:36:52 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/${pname}
|
|
|
|
|
2021-05-03 20:48:10 +00:00
|
|
|
icotool --extract $out/opt/STM32CubeMX/help/${iconame}.ico
|
|
|
|
fdupes -dN . > /dev/null
|
2020-04-24 23:36:52 +00:00
|
|
|
ls
|
|
|
|
for size in 16 24 32 48 64 128 256; do
|
|
|
|
mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps
|
2021-05-03 20:48:10 +00:00
|
|
|
if [ $size -eq 256 ]; then
|
|
|
|
mv ${iconame}_*_"$size"x"$size"x32.png \
|
2020-04-24 23:36:52 +00:00
|
|
|
$out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
|
|
|
|
else
|
2021-05-03 20:48:10 +00:00
|
|
|
convert -resize "$size"x"$size" ${iconame}_*_256x256x32.png \
|
2020-04-24 23:36:52 +00:00
|
|
|
$out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
|
|
|
|
fi
|
|
|
|
done;
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-08-20 17:08:02 +00:00
|
|
|
description = "A graphical tool for configuring STM32 microcontrollers and microprocessors";
|
|
|
|
longDescription = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A graphical tool that allows a very easy configuration of STM32
|
|
|
|
microcontrollers and microprocessors, as well as the generation of the
|
|
|
|
corresponding initialization C code for the Arm® Cortex®-M core or a
|
|
|
|
partial Linux® Device Tree for Arm® Cortex®-A core), through a
|
2020-11-15 13:44:38 +00:00
|
|
|
step-by-step process.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
homepage = "https://www.st.com/en/development-tools/stm32cubemx.html";
|
2022-06-16 17:23:12 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.unfree;
|
|
|
|
maintainers = with maintainers; [ wucke13 ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|