Month: June 2017

Netbeans minimap, scale factor

If you are editing a file that most of the lines are very short, only few lines are very long. Minimap use the exact line length to render the map, so it doesn’t look very clear. See below. But you can manually adjust the scale factor by right clicking the setting menu on the minimap.

read count : 16

NUCLEO-L476RG

https://developer.mbed.org/platforms/ST-Nucleo-L476RG/

Affordable and flexible platform to ease prototyping using a STM32L476RGT6 microcontroller.

Overview

The STM32 Nucleo board provides an affordable and flexible way for users to try out new ideas and build prototypes with any STM32 microcontroller line, choosing from the various combinations of performance, power consumption and features.

The Arduino™ connectivity support and ST Morpho headers make it easy to expand the functionality of the STM32 Nucleo open development platform with a wide choice of specialized shields.

The STM32 Nucleo board does not require any separate probe as it integrates the ST-LINK/V2-1 debugger/programmer.

Microcontroller features

  • STM32L476RGT6 in LQFP64 package
  • ARM®32-bit Cortex®-M4 CPU
  • Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from Flash memory
  • 80 MHz max CPU frequency
  • VDD from 1.71 V to 3.6 V
  • 1 MB Flash
  • 128 KB SRAM
  • random generator (TRNG for HW entropy)
  • Quad SPI (1)
  • Timers General Purpose (7)
  • Timers Advanced-Control (2)
  • Timers Basic (2)
  • Timers LowPower (2)
  • Systick
  • Watchdog (2)
  • SPI (3)
  • I2C (3)
  • USART (3)
  • UART (2)
  • LPUART (1)
  • USB OTG Full Speed
  • CAN (1)
  • SAI (2)
  • SDMMC
  • SWPMI
  • LCD 8×28 or 4×32
  • GPIO (51) with external interrupt capability
  • Capacitive sensing with 12 channels
  • 12-bit ADC (3) with 16 channels
  • 12-bit DAC with 2 channels
  • Analog comparator (2)
  • Opamp (2)

Nucleo features

  • Two types of extension resources
    • Arduino Uno Revision 3 connectivity
    • STMicroelectronics Morpho extension pin headers for full access to all STM32 I/Os
  • On-board ST-LINK/V2-1 debugger/programmer with SWD connector
    • Selection-mode switch to use the kit as a standalone ST-LINK/V2-1
  • Flexible board power supply
    • USB VBUS or external source (3.3 V, 5 V, 7 – 12 V)
    • Power management access point
  • User LED (LD2)
  • Two push buttons: USER and RESET
  • USB re-enumeration capability: three different interfaces supported on USB
    • Virtual Com port
    • Mass storage (USB Disk drive) for drag’n’drop programming
    • Debug port

Nucleo pinout

Arduino-compatible headers

/media/uploads/jeromecoutant/nucleo_l476rg_arduino_left_2017_4_21.png/media/uploads/jeromecoutant/nucleo_l476rg_arduino_right_2017_4_21.png

Morpho headers

These headers give access to all STM32 pins.

/media/uploads/jeromecoutant/nucleo_l476rg_morpho_left_2017_4_21.png/media/uploads/jeromecoutant/nucleo_l476rg_morpho_right_2017_4_21.png

Information

Only the labels written in blue/white or green/white (i.e. PA_4, PB_5, A0, D14, LED1…) must be used in your code. The other labels are given as information (alternate-functions, power pins, …).

You can find more details on the available pins and labels in the following files (link to the latest mbed-dev library version):

Supported shields

ST X-NUCLEO boards

See Matrix of tested boards.

Other Non-ST boards

See here.

Getting started

Nucleo ST-LINK/V2 driver installation and firmware upgrade

  • Install the ST-LINK/V2 driver before connecting the Nucleo board to your PC the first time. Follow this LINK for all details.
  • For optimum performances, ensure that the Nucleo ST-LINK/V2 firmware is upgraded to the latest version. Follow this LINK for all details.

Technical references

For more information, please refer to:

Known limitations

The following section describes known limitations of the platform. Note that general issues are tracked into the mbed repositoryavailable on GitHub.

This platform does not present any limitation.

read count : 5

Maven runner now provide API for other module to interact

Maven runner (https://github.com/mcheung63/MavenRunner) works now.  MavenRunnerServiceImpl works, so everybody can interacte with Maven Runner by code. Now supported two functions : run(projectName, goal) and selectNode(projectName, goal). Example below, it will select a node in Maven Runner treeview.

MavenRunnerService mavenRunnerService = Lookup.getDefault().lookup(MavenRunnerService.class);
ModuleLib.log("mavenRunnerService=" + mavenRunnerService);
if (mavenRunnerService != null) {
mavenRunnerService.selectNode("General Kernel Debugger", "build");
}

Thanks for the supports to everyone in the netbeans dev mailling list.

read count : 3

[Solved] Netbeans : Failed executing NetBeans: Error while executing process. Cannot run program

If you are doing netbeans plugin development and having this error, that mean the nbm-maven-plugin has detected your netbeans wrongly. You can manually set the variable to your current netbeans directory, it will be fixed.

Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:4.1:run-ide (default-cli) on project netbeans-minimap: Failed executing NetBeans: Error while executing process. Cannot run program “/Applications/NetBeans/NetBeans 8.0.2.app/Contents/Resources/NetBeans/bin/netbeans”: error=2, No such file or directory -> [Help 1]

read count : 7

Upgraded to Netbeans 8.2, my minimap plugin can’t run

Upgraded to Netbeans 8.2, my minimap plugin can’t run, because it said i am using a wrong version of “Editor Lib 2”.

The STUPID fix to this problem is that i build the nbm, copy the “OpenIDE-Module-Module-Dependencies” from target/classes/META-INF/MANIFEST.MF , manually modify the version number, then pack it again. I don’t think this is a long term solution 🙁 so i won’t publish it to netbeans plugin central, i scare crashing somebody netbeans.

read count : 38

Netbeans api has bug, the west slidebar not always align to top

Netbeans api has bug, the west slidebar not always align to top, here my layout.xml

		<folder name="SideBar">
			<file name="com-pdk-sidebar-AddressSideBarFactory.instance">
				<attr name="position" intvalue="0"/>
				<attr name="location" stringvalue="West"/>
				<attr name="scrollable" boolvalue="true"/>
			</file>
		</folder>

package com.pdk.sidebar;

import com.pdk.NetbeansUtil;
import com.pdk.ToggleAddressSideBarAction;
import com.peterdwarf.dwarf.Dwarf;
import com.peterdwarf.dwarf.DwarfLib;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Vector;
import javax.swing.JComponent;
import javax.swing.text.JTextComponent;
import org.netbeans.api.project.Project;
import org.openide.loaders.DataObject;
import org.openide.util.Lookup;
import org.openide.util.Utilities;

public class AddressSideBarFactory implements org.netbeans.spi.editor.SideBarFactory {

	public static ArrayList<AddressPanel> addressPanels = new ArrayList<AddressPanel>();
	public static AddressPanel addressPanel;

	@Override
	public JComponent createSideBar(JTextComponent jtc) {
		AddressSideBarFactory.addressPanel = new AddressPanel(jtc);
		addressPanels.add(addressPanel);
		addressPanel.setOpaque(false);
		addressPanel.setVisible(ToggleAddressSideBarAction.visible);
		int width = jtc.getFontMetrics(jtc.getFont()).stringWidth("00000000");
		addressPanel.setPreferredSize(new Dimension(width, 10));
		Project project = NetbeansUtil.getProject();
		if (project != null) {
			if (!project.getProjectDirectory().getName().toLowerCase().equals("peteri")) {
				return null;
			}
			Lookup context = Utilities.actionsGlobalContext();
			DataObject file = context.lookup(DataObject.class);
			if (file != null) {
				//File dir = new File(file.getFolder().getPrimaryFile().getPath());

				File fileObj = new File(file.getPrimaryFile().getPath());
				String filename = fileObj.getName().toLowerCase();
				if (filename.endsWith(".c") || filename.endsWith(".cpp") || filename.endsWith(".cc") || filename.endsWith(".s") || filename.endsWith(".asm")) {
//					jtc.addCaretListener(new CaretListener() {
//						@Override
//						public void caretUpdate(CaretEvent e) {
//							addressPanel.repaint();
//						}
//					});

					jtc.addMouseListener(new MouseListener() {
						@Override
						public void mouseClicked(MouseEvent e) {

						}

						@Override
						public void mousePressed(MouseEvent e) {
							addressPanel.repaint();
						}

						@Override
						public void mouseReleased(MouseEvent e) {

						}

						@Override
						public void mouseEntered(MouseEvent e) {

						}

						@Override
						public void mouseExited(MouseEvent e) {

						}
					});
					Vector<Dwarf> dwarfVector = DwarfLib.init(new File("/Users/peter/workspace/PeterI/kernel/kernel"), 0, false);
					Hashtable<Integer, BigInteger> ht = DwarfLib.getAddresses(dwarfVector, fileObj.getName());
					addressPanel.lineInfo = ht;
				} else {
					return null;
				}
			}

		}

		return addressPanel;
	}
}
package com.pdk.sidebar;

import com.pdk.ModuleLib;
import com.pdk.ToggleAddressSideBarAction;
import com.peterswing.CommonLib;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.math.BigInteger;
import java.util.Hashtable;
import javax.swing.JPanel;
import javax.swing.plaf.TextUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
import javax.swing.text.StyledDocument;
import javax.swing.text.View;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.editor.settings.FontColorNames;
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.editor.BaseTextUI;
import org.netbeans.editor.Coloring;
import org.netbeans.editor.Utilities;
import org.openide.text.NbDocument;

public class AddressPanel extends JPanel {

	private final JTextComponent jtc;
	Hashtable<Integer, BigInteger> lineInfo;
	TextUI textUI;
	View rootView;
	Color backgroundColor = Color.decode("#eaeaea");

	AddressPanel(JTextComponent jtc) {
		this.jtc = jtc;

		textUI = jtc.getUI();
		rootView = Utilities.getDocumentView(jtc);
	}

	@Override
	public void paint(final Graphics g) {
		if (!ToggleAddressSideBarAction.visible) {
			return;
		}
		super.paint(g);
//		ModuleLib.log(this.getParent());
//		ModuleLib.log(this.getParent().getParent());
		((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		g.setFont(jtc.getFont());
		g.setColor(backgroundColor);
		g.fillRect(0, 0, getWidth(), getHeight());

		Document document = jtc.getDocument();
		//HighlightsContainer hc = HighlightingManager.getInstance(jtc).getBottomHighlights();
		//HighlightsSequence hq = hc.getHighlights(0, document.getLength());

		FontMetrics metrics = g.getFontMetrics(jtc.getFont());
		int fontHeight = metrics.getHeight();

		int lineNo = document.getDefaultRootElement().getElementIndex(jtc.getCaretPosition());
		//ModuleLib.log("lineNo=" + lineNo + ", " + fontHeight);
		FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class);
		Coloring c = Coloring.fromAttributeSet(fcs.getFontColors(FontColorNames.CARET_ROW_COLORING));
		g.setColor(c.getBackColor());
		g.fillRect(0, fontHeight * lineNo, getWidth(), fontHeight);

		if (lineInfo != null) {
			try {
				if (rootView == null) {
					return;
				}
				int startPos = getPosFromY(jtc, textUI, 0);
				int startViewIndex = rootView.getViewIndex(startPos, Position.Bias.Forward);
				int rootViewCount = rootView.getViewCount();

				if (startViewIndex >= 0 && startViewIndex < rootViewCount) {
					g.setColor(Color.gray);
					int y = 0;
					for (int i = startViewIndex; i < rootViewCount; i++) {
						View view = rootView.getView(i);
						if (view == null) {
							break;
						}
						lineNo = NbDocument.findLineNumber((StyledDocument) document, view.getStartOffset());

						//g.drawString(String.valueOf(lineNo + 1), 0, (StyleConstants.getFontSize(as) + 5) * lineNo + 14);
						//int firstMargin = (fontHeight - StyleConstants.getFontSize(as)) / 2;
						BigInteger address = lineInfo.get(lineNo + 1);
						//ModuleLib.log(lineInfo + " = " + String.format("%08X", address));
						if (address != null) {
							g.drawString(String.format("%08X", address), 0, fontHeight * (y + 1) - 3);
						}
						y++;
						//ModuleLib.log("lineNo=" + lineNo);
					}
				}
			} catch (Exception ex) {
				ModuleLib.log(CommonLib.printException(ex));
			}
		}
	}

	private int getPosFromY(JTextComponent component, TextUI textUI, int y) throws BadLocationException {
		if (textUI instanceof BaseTextUI) {
			return ((BaseTextUI) textUI).getPosFromY(y);
		} else {
			// fallback to ( less otimized than ((BaseTextUI) textUI).getPosFromY(y) )
			return textUI.modelToView(component, textUI.viewToModel(component, new Point(0, y))).y;
		}
	}
}

read count : 29